Thread overview
[Issue 6137] New: [CTFE] Foreach on semantically wrong initialized array crashes the compiler
Jun 09, 2011
timon.gehr@gmx.ch
Jun 10, 2011
timon.gehr@gmx.ch
Jun 10, 2011
Don
June 09, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6137

           Summary: [CTFE] Foreach on semantically wrong initialized array
                    crashes the compiler
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: timon.gehr@gmx.ch


--- Comment #0 from timon.gehr@gmx.ch 2011-06-09 16:10:04 PDT ---
The following (invalid) code segfaults DMD (2.053).

enum qux = foo();

int[] bar = [[]*[[]<>[]]*[]]; // can be anything that is not an int[]

int foo(){
    foreach(t;bar){}
    return 0;
}

void main(){}

It does not matter what the initializer of bar is at long as it is not an
int[].
The segmentation fault still occurs if bar is set to immutable.


Compilation output:
Error: static variable bar cannot be read at compile time
Segmentation fault

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 10, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6137


timon.gehr@gmx.ch changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |regression


--- Comment #1 from timon.gehr@gmx.ch 2011-06-10 02:33:49 PDT ---
This bug is introduced with DMD 2.053.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 10, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6137


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |clugdbug@yahoo.com.au
         Resolution|                            |FIXED


--- Comment #2 from Don <clugdbug@yahoo.com.au> 2011-06-10 12:14:53 PDT ---
Fixed in git master, as part of the fixes to CTFE references. https://github.com/D-Programming-Language/dmd/pull/69

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