Thread overview
[Issue 5090] New: Assertion `sz <= vsz' failed with struct literal initializing zero length array
Oct 20, 2010
Iain Buclaw
[Issue 5090] ICE(todt.c) struct literal initializing zero length array
Nov 15, 2010
simon
Nov 15, 2010
Iain Buclaw
Dec 09, 2010
Iain Buclaw
Dec 09, 2010
Iain Buclaw
Dec 27, 2010
Walter Bright
October 20, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5090

           Summary: Assertion `sz <= vsz' failed with struct literal
                    initializing zero length array
           Product: D
           Version: D1 & D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: ibuclaw@ubuntu.com


--- Comment #0 from Iain Buclaw <ibuclaw@ubuntu.com> 2010-10-20 16:14:46 PDT ---
Test cases:

struct A { int[0] b; }
A a = A(0); // Fails, compiler aborts
A b = {b:0}; // OK, but perhaps shouldn't be.
A c = A([]); // OK
A d = {b:[]}; // OK



Although the compiler shouldn't issue an assert, a zero length array should be enforced to have a 0 length initializer.

Regards

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 20, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5090


bearophile_hugs@eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs@eml.cc


--- Comment #1 from bearophile_hugs@eml.cc 2010-10-20 16:35:32 PDT ---
This needs to be an error, because that 0 value has nowhere to be stored into:

struct A { int[0] b; }
A b = {b : 0};

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 15, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5090


simon <s.d.hammett@googlemail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|nobody@puremagic.com        |s.d.hammett@googlemail.com


--- Comment #2 from simon <s.d.hammett@googlemail.com> 2010-11-15 11:33:15 PST ---
Created an attachment (id=813)
PATCH against rev 755: fix crash in first case

Fixed:

A a = A(0); // Fails, compiler aborts

by issuing error msg.

I'll dig a bit more into fixing the second case, that should be an error as way.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 15, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5090



--- Comment #3 from Iain Buclaw <ibuclaw@ubuntu.com> 2010-11-15 12:11:09 PST ---
Just under the "duplicate union" error is where to look iirc.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 09, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5090



--- Comment #4 from Iain Buclaw <ibuclaw@ubuntu.com> 2010-12-09 07:42:07 PST ---
Created an attachment (id=844)
Patch for 5090

Reassigned to Walter. Attaching patch that turns assert into an error, but enforces that this corner case only happens for zero-length'd static arrays.

Make any improvements you may wish to add/remove, as I generally suck at coming up with good, concise error messages. :~)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 09, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5090



--- Comment #5 from Iain Buclaw <ibuclaw@ubuntu.com> 2010-12-09 07:48:08 PST ---
Just to make note, these forms of initialisation are still OK for zero-length static arrays:

struct A { int[0] b; }
A a = A();    // OK
A b = {};     // OK
A c = A([]);  // OK
A d = {b:[]}; // OK


Regards

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 27, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5090


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


--- Comment #6 from Walter Bright <bugzilla@digitalmars.com> 2010-12-27 15:23:49 PST ---
http://www.dsource.org/projects/dmd/changeset/823

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