www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3246] New: ICE(init.c) using indexed array initializer on local array

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: clugdbug 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: -------
Aug 12 2009
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3246


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED





13:27:57 PDT ---
Fixed dmd 1.047 and 2.032

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