Bug 4238 – Segfault(statement.c): with(typeof(int))

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
Other
OS
Windows
Creation time
2010-05-26T13:03:00Z
Last change time
2014-02-16T15:22:27Z
Keywords
ice-on-invalid-code, patch
Assigned to
nobody
Creator
clugdbug

Comments

Comment #0 by clugdbug — 2010-05-26T13:03:03Z
TEST CASE: ----- void bug4237() { int s; with(typeof(s)) {} } ---- PATCH (D2 svn 502): // WithStatement::semantic. line 3639: segfaults because toDsymbol(sc) // returns null. { TypeExp *es = (TypeExp *)exp; - sym = es->type->toDsymbol(sc)->isScopeDsymbol(); + Dsymbol *dsym = es->type->toDsymbol(sc); + sym = dsym ? dsym->isScopeDsymbol() : NULL; if (!sym) { error("%s has no members", es->toChars()); body = body->semantic(sc); return this; } }
Comment #1 by clugdbug — 2010-05-26T13:20:16Z
Darn it, waited to long before hitting submit, and another bug snuck in before this one -- test case should be changed to bug4238(). <g>. Anyway, if you add one line to the patch, it fixes bug 1413. I was actually trying to generate a case where 1413 matters, but failed. But I found this case instead. PATCH (D2 svn 502): // WithStatement::semantic. line 3639: segfaults because toDsymbol(sc) // returns null. { TypeExp *es = (TypeExp *)exp; - sym = es->type->toDsymbol(sc)->isScopeDsymbol(); + Dsymbol *dsym = es->type->toDsymbol(sc); + sym = dsym ? dsym->isScopeDsymbol() : NULL; if (!sym) { error("%s has no members", es->toChars()); + if (body) body = body->semantic(sc); return this; } }
Comment #2 by bugzilla — 2010-06-28T11:59:09Z