Bug 3575 – CTFE: member structs not initialized correctly

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
Other
OS
Windows
Creation time
2009-12-05T01:54:00Z
Last change time
2014-04-18T09:12:03Z
Keywords
patch, rejects-valid
Assigned to
nobody
Creator
clugdbug

Attachments

IDFilenameSummaryContent-TypeSize
522patch3575.patchPatch against DMD2.037 svn 283.text/plain4795

Comments

Comment #0 by clugdbug — 2009-12-05T01:54:25Z
This is a couple of cases I missed in my CTFE patches in DMD2.032. Root cause: defaultInit for a struct is a VarExp, not a StructLiteral. This needs to be applied recursively. Patch: I've added a recursive defaultInitAsStructLiteral() to TypeStruct. It needs to be called from two places in interpret.c. --------------------------------- struct SwineFlu { int a; int b; } struct Infection { SwineFlu y; } struct IveGotSwineFlu { Infection x; int z; int oink() { return x.y.a+10; } } int quarantine() { IveGotSwineFlu d; return d.oink(); } struct Mexico { Infection x; int z=2; int oink() { return z+x.y.b; } } int mediafrenzy() { Mexico m; return m.oink; } static assert( quarantine() == 10); static assert( mediafrenzy() == 2);
Comment #1 by clugdbug — 2009-12-05T01:56:24Z
Created attachment 522 Patch against DMD2.037 svn 283.
Comment #2 by bugzilla — 2009-12-30T00:11:37Z
Changeset 321
Comment #3 by bugzilla — 2009-12-31T11:12:24Z
Fixed dmd 1.054 and 2.038