digitalmars.D.bugs - [Issue 1753] New: String corruption in recursive CTFE functions
- d-bugmail puremagic.com (35/35) Dec 29 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1753
- d-bugmail puremagic.com (9/9) Jan 02 2008 http://d.puremagic.com/issues/show_bug.cgi?id=1753
http://d.puremagic.com/issues/show_bug.cgi?id=1753 Summary: String corruption in recursive CTFE functions Product: D Version: 1.024 Platform: PC OS/Version: Windows Status: NEW Keywords: wrong-code Severity: major Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: clugdbug yahoo.com.au 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"); --------- --
Dec 29 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1753 clugdbug yahoo.com.au changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED ------- Comment #1 from clugdbug yahoo.com.au 2008-01-02 09:15 ------- Fixed DMD 1.025 --
Jan 02 2008