[Issue 2829] ICE(expression.c) static array block-initialized in struct literal
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jun 2 16:25:15 PDT 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2829
Don <clugdbug at yahoo.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch, rejects-valid
Summary|ICE(expression.c) accessing |ICE(expression.c) static
|out of bounds element in a |array block-initialized in
|static array constant |struct literal
|initialized through struct |
|literal |
OS/Version|Linux |All
--- Comment #1 from Don <clugdbug at yahoo.com.au> 2009-06-02 16:25:14 PDT ---
Title was: ICE(expression.c) accessing out of bounds element in a static array
constant initialized through struct literal
Changed since it is more general. Applies to D2 as well as D1.
-- ANALYSIS --
This is crashing in constfold.c, line 1218, crashing while doing e1->toChars()
while printing the error message. But there are also rejects-valid bugs with
the
same root cause: block assignment of arrays is buggy.
The root cause is expression.c, StructLiteralExp::getField().
In the line e->type=type is incorrect if e->type is of type K, and 'type'
is a static array of type K.
PATCH: in such cases, create and populate an array literal.
--- expression.c (revision 27)
+++ expression.c (working copy)
@@ -3236,7 +3236,18 @@
if (e)
{
e = e->copy();
+ if (e->type != type && type->ty == Tsarray)
+ { TypeSArray *tsa = (TypeSArray *)type;
+ uinteger_t length = tsa->dim->toInteger();
+ Expressions * z = new Expressions;
+ z->setDim(length);
+ for (int q=0; q<length; ++q) z->data[q] = e->copy();
+ ArrayLiteralExp * ac = new ArrayLiteralExp(loc, z);
+ ac -> type = type;
+ e = ac;
+ } else {
e->type = type;
+ }
}
}
return e;
== TEST CASE 2 -- ICE(expression.c) == For D2, change 'enum' to 'const' for D1.
struct S { int i[3]; }
enum S s = S(8);
int * p = & s.i;
// Test case 3 -- rejects-valid
struct Q { double i[3]; }
enum Q q = Q(8.0*real.min);
const x = q.i[2];
--
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