[Issue 3974] ICE(init.c): Static array initializer with more elements than destination array
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Apr 9 13:35:50 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3974
Don <clugdbug at yahoo.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch
--- Comment #2 from Don <clugdbug at yahoo.com.au> 2010-04-09 13:35:44 PDT ---
Note to bearophile: The case where the number of elements is LESS than the
array size (bug 3849) is quite different. Note that, for example,
int [3] x = [ 2: 15]; is currently legal.
This patch is slightly more general, in that it covers the cases like
int[3] toomany = [ 2: 13, 1];
PATCH: init.c line 343 (in ArrayInitializer::semantic()).
if (length == 0)
error(loc, "array dimension overflow");
if (length > dim)
dim = length;
}
+ if (t->ty == Tsarray)
+ {
+ size_t edim = ((TypeSArray *)t)->dim->toInteger();
+ if (dim > edim)
+ {
+ error(loc, "array initializer has %d elements, but array length is
%d", dim, edim);
+ return new ExpInitializer(loc, new ErrorExp());
+ }
+ }
unsigned long amax = 0x80000000;
if ((unsigned long) dim * t->nextOf()->size() >= amax)
error(loc, "array dimension %u exceeds max of %ju", dim, amax /
t->nextOf()->size());
--
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