Bug 4252 – [CTFE]: No array bounds checking in assignment to char[] array
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2010-05-30T08:05:00Z
Last change time
2014-02-15T02:42:43Z
Keywords
rejects-valid
Assigned to
nobody
Creator
clugdbug
Comments
Comment #0 by clugdbug — 2010-05-30T08:05:01Z
This code shouldn't compile, due to the array bounds error. But instead, compiler memory corruption occurs.
int bug4252()
{
char [] s = "abc".dup;
s[5] = 'd';
return 3;
}
static assert(bug4252());
The revision that fixed this also fixed a missing line number bug. Looking at the source, it did so by calling a error function with a Loc value rather than without it. My question is why the original function even exists? When would the compiler ever need to dump an error message and not have a line number to attach to it?