www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8949] New: [CTFE] Internal Compiler Error

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8949

           Summary: [CTFE] Internal Compiler Error
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: zan77137 nifty.com



This code doesn't work:

string test()
{
    import std.csv;
    static struct Layout  { string a, b; }
    static struct MapData { string[string] map; }
    MapData md;
    foreach (data; csvReader!Layout("a,"))
    {
        md.map[data.a] = data.b;
    }
    return md.map.get("b", null);
}

void main()
{
    //import std.stdio;
    //writeln(test());     // <- OK
    pragma(msg, test());   // <- NG
}

Result:
main.d(9): Error: Internal Compiler Error: CTFE literal Layout(['a'],null).b
Assertion failure: '0' on line 353 in file 'ctfeexpr.c'

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 02 2012
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8949




Reduced test case:

struct S { int[int] a; }

void baz(ref int[int] x)
{
   auto m = x.dup;
}

int bar()
{
    S s;
    baz(s.a);
    return 1;
}

static assert(bar());
---
Applies to any case where you pass an AA by reference _when it is null_, and
then duplicate it. <sigh> This is the bizarre "magic null" semantics that
happen only with AAs. It causes dozens of special cases.

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