Bug 1072 – CTFE: crash on for loop with blank increment
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
All
Creation time
2007-03-20T02:44:00Z
Last change time
2014-02-16T15:26:25Z
Keywords
ice-on-valid-code, patch
Assigned to
bugzilla
Creator
davidl
Comments
Comment #0 by davidl — 2007-03-20T02:44:17Z
static char[] hello()
{
char[] result="";
for(;;)
result ~= `abc`;
return result;
}
void main()
{
pragma(msg,hello());
}
this code should also make ur computer DoS, but DMD AV
this code won't make dmd access violation:
static char[] hello()
{
char[] result="";
int i;
for(;;i++)
result ~= `abc`;
return result;
}
void main()
{
pragma(msg,hello());
}
the problem is intepret.c line 594, it assumes increment is an object which is never null, while in this case, the loop doesn't have any increment statement.
So a quick fix is
add to line 594
if (!increment)
continue;
Comment #3 by davidl — 2007-12-09T19:17:19Z
*** Bug 1696 has been marked as a duplicate of this bug. ***
Comment #4 by clugdbug — 2007-12-18T09:27:29Z
added keywords. Walter probably missed this one because the bug title is terrible!
Comment #5 by matti.niemenmaa+dbugzilla — 2007-12-18T12:30:55Z