Bug 4529 – Segfault(typinf.c) involving typeid(typeof(functionName))

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2010-07-28T15:27:00Z
Last change time
2010-11-11T19:01:16Z
Keywords
ice-on-valid-code, patch
Assigned to
nobody
Creator
bearophile_hugs

Comments

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;
Comment #3 by bugzilla — 2010-11-11T19:01:16Z