Bug 1204 – segfault using struct in CTFE

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
All
Creation time
2007-04-30T14:53:00Z
Last change time
2014-02-16T15:21:54Z
Assigned to
bugzilla
Creator
clugdbug

Comments

Comment #0 by clugdbug — 2007-04-30T14:53:00Z
Seems to be a memory corruption problem. Doesn't happen if unused, unused2 are removed. --------- struct V { int a; int b; } V f() { int q = 0; int unused; int unused2; return V(q, 0); } void main() { const w = f(); } ========================== Probably more helpful is this version, which prints: No expression copy for: unused just before it crashes. ------------------------ struct V { int a; int b; } V f() { int q = 0; int unused; int unused2; return V(q, 0); } void main() { const w = f().b; }
Comment #1 by thomas-dloop — 2007-05-07T00:18:07Z
Comment #2 by witold.baryluk+d — 2007-05-19T08:27:07Z
Another example or problem with struct and char literals in CTFE: import std.stdio; struct Col2Spec { char[] type; char[] name; } char[] f() { char[] id = "x", id2 = "y"; Col2Spec a = Col2Spec(id,"a"); // error in CTFE // Col2Spec a = Col2Spec("b",id2); // works int i = 2; assert(i - i, "Should be 'a', is " ~ a.name); // output, line: 13 return "ret"; } void main() { const static char[] w = f(); // line: 18 // f(); // works } // sb.d(18): Error: cannot evaluate f() at compile time
Comment #3 by bugzilla — 2007-07-01T14:00:00Z
Fixed DMD 1.018 and DMD 2.002