[Issue 2437] ICE(tocsym.c, !needThis()) - default struct argument
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Apr 12 13:51:16 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=2437
--- Comment #5 from Don <clugdbug at yahoo.com.au> 2010-04-12 13:51:13 PDT ---
See also the closely related bug 2935.
I can patch this (against svn 433) with these two changes (and the DMD test
suite still passes), which basically just remove the checks, in the case where
a CTFE variable is used. I'm not certain these patches are correct, though.
-- PATCH ------------------------------------------
tocsym.c, line 170:
Symbol *VarDeclaration::toSymbol()
{
//printf("VarDeclaration::toSymbol(%s)\n", toChars());
//if (needThis()) *(char*)0=0;
+ if (!isCTFE())
assert(!needThis());
and secondly, in e2ir.c, SymbolExp::toElem() line 664:
//printf("SymbolExp::toElem('%s') %p\n", toChars(), this);
//printf("\tparent = '%s'\n", var->parent ? var->parent->toChars() :
"null");
- if (op == TOKvar && var->needThis())
+ if (op == TOKvar && var->needThis() && !v->isCTFE())
{
error("need 'this' to access member %s", toChars());
return el_long(TYint, 0);
}
---------------------------------
A totally different (and probably better) alternative would be to fix it in
expression.c, around line 6770, when the temporary variable is created. If
(!sc->func), it's being created in global scope, and should be neither in
STCfield nor STCextern storage class. But I'm not sure how this should be done.
// First look for constructor
if (ad->ctor && arguments && arguments->dim)
{
// Create variable that will get constructed
Identifier *idtmp = Lexer::uniqueId("__ctmp");
VarDeclaration *tmp = new VarDeclaration(loc, t1, idtmp, NULL);
tmp->storage_class |= STCctfe;
+ if (!sc->func) {
+ // it's being created in global scope. Do something!!
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list