Thread overview | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
November 08, 2009 [Issue 3488] New: Segfault(expression.c): enum declared with struct initializer in template | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=3488 Summary: Segfault(expression.c): enum declared with struct initializer in template Product: D Version: 2.036 Platform: Other OS/Version: Windows Status: NEW Keywords: ice-on-valid-code Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: clugdbug@yahoo.com.au --- Comment #0 from Don <clugdbug@yahoo.com.au> 2009-11-08 08:30:45 PST --- Reported by g in d.learn. Segfaults in expression.c. D2 only. -- struct Move{ int Dx; } template genMove(){ enum Move genMove = { Dx:4 }; } enum Move b = genMove!(); -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
November 08, 2009 [Issue 3488] Segfault(expression.c): enum declared with struct initializer in template | ||||
---|---|---|---|---|
| ||||
Posted in reply to Don | http://d.puremagic.com/issues/show_bug.cgi?id=3488 g <sockpuppet3@hotmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |sockpuppet3@hotmail.com --- Comment #1 from g <sockpuppet3@hotmail.com> 2009-11-08 10:51:30 PST --- also to note that this also don't works: -- struct A{ int n; } template genA(){ enum A genA = { n:4 }; } immutable A b = genA!(); -- but this works: -- struct A{ int n; } template genA(){ //works with immutable immutable A genA = { n:4 }; } immutable A b = genA!(); void main(){ //ok assert(b.n == 4); } -- -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
November 08, 2009 [Issue 3488] Segfault(expression.c): enum declared with struct static initializer | ||||
---|---|---|---|---|
| ||||
Posted in reply to Don | http://d.puremagic.com/issues/show_bug.cgi?id=3488 Don <clugdbug@yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|Segfault(expression.c): |Segfault(expression.c): |enum declared with struct |enum declared with struct |initializer in template |static initializer --- Comment #2 from Don <clugdbug@yahoo.com.au> 2009-11-08 11:32:12 PST --- Further reduced test case shows it doesn't need a template. It's just an enum static initializer problem. --- struct Move{ int Dx; } enum Move genMove = { Dx:4 }; immutable Move b = genMove; --- -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
November 09, 2009 [Issue 3488] Segfault(expression.c): enum declared with struct static initializer | ||||
---|---|---|---|---|
| ||||
Posted in reply to Don | http://d.puremagic.com/issues/show_bug.cgi?id=3488 --- Comment #3 from Don <clugdbug@yahoo.com.au> 2009-11-09 03:24:21 PST --- It's happening because static struct initializers with names are not evaluated at compile time. And this is because init.c, StructInitializer::toExpression() doesn't deal with it. BTW -- now that we have struct literals, I'm not sure that we need struct initializers any more. They're a bit annoying, implementation-wise. --- TEST CASE --- struct Move{ int Dx; } immutable Move genMove = { Dx:4}; static assert(genMove.Dx == 4); // not evaluatable at compile time. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
November 23, 2009 [Issue 3488] Segfault(expression.c): enum declared with struct static initializer | ||||
---|---|---|---|---|
| ||||
Posted in reply to Don | http://d.puremagic.com/issues/show_bug.cgi?id=3488 --- Comment #4 from Don <clugdbug@yahoo.com.au> 2009-11-23 00:23:22 PST --- PATCH: With the demise of struct initializers, it's not worth fixing properly. But DsymbolExp::semantic() should check for a null value anyway (it checks in other places in expression.c). This would prevent the segfault. expression.c line 2306 (svn 267): if ((v->storage_class & STCmanifest) && v->init) { e = v->init->toExpression(); + if (!e) + { error("cannot make expression out of initializer for %s", v->toChars()); + e = new ErrorExp(); + } e->semantic(sc); return e; } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 23, 2010 [Issue 3488] Segfault(expression.c): enum declared with struct static initializer | ||||
---|---|---|---|---|
| ||||
Posted in reply to Don | http://d.puremagic.com/issues/show_bug.cgi?id=3488 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bugzilla@digitalmars.com --- Comment #5 from Walter Bright <bugzilla@digitalmars.com> 2010-01-23 01:19:02 PST --- Changeset 349 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 31, 2010 [Issue 3488] Segfault(expression.c): enum declared with struct static initializer | ||||
---|---|---|---|---|
| ||||
Posted in reply to Don | http://d.puremagic.com/issues/show_bug.cgi?id=3488 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED --- Comment #6 from Walter Bright <bugzilla@digitalmars.com> 2010-01-30 22:44:36 PST --- fixed dmd 2.040 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation