[Issue 1753] New: String corruption in recursive CTFE functions
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Dec 29 03:50:09 PST 2007
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 at digitalmars.com
ReportedBy: clugdbug at 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");
---------
--
More information about the Digitalmars-d-bugs
mailing list