Comment #0 by bearophile_hugs — 2010-07-28T15:27:20Z
D2 code, compiled with dmd 2.047, causes a crash of the compiler:
import std.stdio;
void main() {
string a();
writeln(typeid(typeof(a)));
string function() b;
writeln(typeid(typeof(b)));
}
Comment #1 by andrej.mitrovich — 2010-08-29T19:03:02Z
This affects 2.048 too.
Comment #2 by clugdbug — 2010-11-03T14:11:30Z
REDUCED TEST CASE:
int bug4529a() { return 0; }
int function() bug4529b;
auto ivorBomb1 = typeid(typeof(bug4529a));
auto ivorBomb2 = typeid(typeof(bug4529b));
Note that swapping the order of the two
typinf.c, Type::getTypeInfo() line 152.
The crash is because vtinfo hasn't been initialized. And this happens because we have a funny situation where vtinfo has been set up for the pointee (which is a function), but not yet for the pointer (which is a pointer to a function).
Possibly a more complete solution would be to disallow typeof(X) where X is a function; if so, an assert(vtinfo) should still be added at this line.
------
t->vtinfo->toObjFile(global.params.multiobj);
}
}
}
+ if (!vtinfo)
+ vtinfo = t->vtinfo;
Expression *e = new VarExp(0, t->vtinfo);
e = e->addressOf(sc);
e->type = t->vtinfo->type; // do this so we don't get redundant dereference
return e;