Thread overview
[Issue 3978] New: Compiler crash on improper struct initialization
Mar 17, 2010
Paul D. Anderson
Mar 19, 2010
Don
March 17, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3978

           Summary: Compiler crash on improper struct initialization
           Product: D
           Version: 2.030
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: paul.d.anderson@comcast.net


--- Comment #0 from Paul D. Anderson <paul.d.anderson@comcast.net> 2010-03-16 17:18:14 PDT ---
The following code fragment causes the compiler to crash with the following useful information:

"dmd.exe has encountered a problem and needs to close.  We are sorry for the inconvenience."

//--------------------
public S s = S();

public struct S {
    private int[] a = [ 0 ];
}
//--------------------

I realize the code is incorrect, but I expected an error message, not a trainwreck.

Adding initializer information solves the problem:

//--------------------
public S s = S([0]); // compiles correctly

public struct S {
    private int[] a = [ 0 ];
}
//--------------------

Eliminating the forward reference solves the problem:

//--------------------
public struct S {
    private int[] a = [ 0 ];
}

public S s = S(); // compiles correctly
//--------------------

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


bearophile_hugs@eml.cc changed:

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


--- Comment #1 from bearophile_hugs@eml.cc 2010-03-16 18:10:41 PDT ---
I think that removing the forward reference doesn't solve the problem.

If I add this line at the end:
void main() {}
The situation changes.

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


Don <clugdbug@yahoo.com.au> changed:

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


--- Comment #2 from Don <clugdbug@yahoo.com.au> 2010-03-19 06:59:43 PDT ---
This was fixed in DMD 2.036.

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