Bug 1753 – String corruption in recursive CTFE functions

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2007-12-29T05:50:00Z
Last change time
2014-02-24T15:32:34Z
Keywords
wrong-code
Assigned to
bugzilla
Creator
clugdbug

Comments

Comment #0 by clugdbug — 2007-12-29T05:50:08Z
In the code below, the call to bar(foo("YYY", "A")) clobbers the old value of f, (should be "A") with the return value of the function. Halfway through the function, the value of f changes to be "@@@" ! This results in silent generation of bad code. I encountered this in BLADE. Took a long time to track this down, even longer to reduce it. Further simplification is probably possible, but I'm sick of it now <g>. ----- char [] bar(char [] z) { return z; } char[] foo(char [] a, char [] b) { char [] f = a.length==1 ? a: foo("B", "C"); if (a.length==1) assert(f.length==1); // OK char [] g = b.length==1 ? b: bar(foo("YYY", "A")); if (a.length==1) assert(f.length==1); // fails! return "@@@"; } const char [] xxx = foo("A", "xxx"); ---------
Comment #1 by clugdbug — 2008-01-02T09:15:47Z
Fixed DMD 1.025