[Issue 3246] New: ICE(init.c) using indexed array initializer on local array
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Aug 12 05:27:30 PDT 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3246
Summary: ICE(init.c) using indexed array initializer on local
array
Product: D
Version: 1.046
Platform: Other
OS/Version: Windows
Status: NEW
Keywords: ice-on-invalid-code, patch
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: clugdbug at yahoo.com.au
Reported by Ali Cehreli.
void main()
{
int[4] static_1 = [ 3:212 ];
}
PATCH against DMD2.031. We need to make sure the array literal is big enough to
include the last mentioned element.
We need to return ErrorExp, not NULL, otherwise it will still segfault on cases
like int[4] x = [32: 1]; because VerDeclaration::semantic assumes a NULL result
means that it should run semantic on the initializer.
Index: init.c
===================================================================
--- init.c (revision 194)
+++ init.c (working copy)
@@ -422,6 +422,13 @@
else
edim = value.dim;
+ for (size_t i = 0, j = 0; i < value.dim; i++, j++)
+ {
+ if (index.data[i])
+ j = ((Expression *)index.data[i])->toInteger();
+ if (j >=edim) edim = j+1;
+ }
+
elements = new Expressions();
elements->setDim(edim);
for (size_t i = 0, j = 0; i < value.dim; i++, j++)
@@ -464,7 +471,7 @@
Lno:
delete elements;
error(loc, "array initializers as expressions are not allowed");
- return NULL;
+ return new ErrorExp();
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list