Bug 4611 – stack overflow or ICE(cgcod.c) when static array of structs exceeds 16MB limit
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-08-10T07:22:00Z
Last change time
2015-06-09T05:11:54Z
Keywords
ice, wrong-code
Assigned to
nobody
Creator
hoganmeier
Comments
Comment #0 by hoganmeier — 2010-08-10T07:22:54Z
void main()
{
const int w = 1024, h = 768;
Vec[w*h] a;
}
struct Vec
{
double x,y,z;
}
This doesn't yield an error message, it just crashes with Stack Overflow.
The following patch also works in the forward reference case shown above. I wonder why class was in that list but not struct:
Index: G:/dmd/src/dmd/mtype.c
===================================================================
--- G:/dmd/src/dmd/mtype.c (revision 608)
+++ G:/dmd/src/dmd/mtype.c (working copy)
@@ -3351,6 +3351,7 @@
tbn->ty == Tarray ||
tbn->ty == Tsarray ||
tbn->ty == Taarray ||
+ tbn->ty == Tstruct ||
tbn->ty == Tclass)
{
/* Only do this for types that don't need to have semantic()
* run on them for the size, since they may be forward referenced.
*/
Comment #1 by hoganmeier — 2010-08-10T07:31:31Z
Never mind, class is in that list because size() simply returns PTRSIZE.
So the question is if there are any forward reference cases where this patch fails because of
unsigned AggregateDeclaration::size(Loc loc)
{
//printf("AggregateDeclaration::size() = %d\n", structsize);
if (!members)
error(loc, "unknown size");
if (sizeok != 1 && scope)
semantic(NULL);
if (sizeok != 1)
{ error(loc, "no size yet for forward reference");
//*(char*)0=0;
}
return structsize;
}
Comment #2 by clugdbug — 2010-12-05T23:45:50Z
This variation is ICE(cgcod.c):
struct Vec
{
int x;
}
void main()
{
Vec[1000_000_000] a;
}