[Issue 3026] New: ICE using static array initializer at compile time

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue May 26 14:34:47 PDT 2009


http://d.puremagic.com/issues/show_bug.cgi?id=3026

           Summary: ICE using static array initializer at compile time
           Product: D
           Version: 2.030
          Platform: PC
        OS/Version: All
            Status: NEW
          Keywords: ice-on-valid-code, patch, rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: rsinfu at gmail.com


Created an attachment (id=382)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=382)
Fix the problem (dmd 2.030)

DMD dies without any error message compiling this valid code:
--------------------
immutable int[2] array = [ 42 ];
enum e = array[1];
--------------------
The array initializer in this code contains one element. In this case
ArrayInitializer::toExpression() wrongly generates an ArrayLiteralExp
of one element, not two elements (notice the int[2]). Then DMD references
missing second element, and dies. The patch fixes this problem.

And DMD rejects this valid code:
--------------------
immutable int[1] array = [ 0: 42 ];
enum e = array[0];
--------------------
test.d(1): Error: array initializers as expressions are not allowed
test.d(1): Error: array initializers as expressions are not allowed
test.d(1): Error: array initializers as expressions are not allowed
test.d(1): Error: array initializers as expressions are not allowed
--------------------
ArrayInitializer::toExpression() does not implement support for array
index in static array initializers. The patch also implements it.

-- 
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