[Issue 2829] ICE(expression.c) static array block-initialized in struct literal

2014-04-18 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=2829

Walter Bright bugzi...@digitalmars.com changed:

   What|Removed |Added

Version|1.043   |D1

--


[Issue 2829] ICE(expression.c) static array block-initialized in struct literal

2009-10-13 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2829


Walter Bright bugzi...@digitalmars.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED


--- Comment #2 from Walter Bright bugzi...@digitalmars.com 2009-10-13 
13:44:51 PDT ---
Fixed dmd 1.049 and 2.034

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 2829] ICE(expression.c) static array block-initialized in struct literal

2009-06-02 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2829


Don clugd...@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 clugd...@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; qlength; ++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: ---