www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1378] New: A function call in an array literal causes compiler to crash

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

           Summary: A function call in an array literal causes compiler to
                    crash
           Product: D
           Version: 2.002
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: critical
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: samukha voliacable.com


dmd 2.003. It doesn't like the call to foo in the first element of the array
literal. 

string foo()
{
    return "";
}

string rod(string[] a)
{
    return a[0];
}

void main()
{
    static x = rod([foo(), ""]); // crash
}

Works, if the result of foo is put into a temporary:

string foo()
{
    return "";
}

string rod(string[] a)
{
    return a[0];
}

void main()
{
    const char[] temp = foo();
    static x = rod([temp, ""]); // ok
}


-- 
Jul 26 2007
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1378


bugzilla digitalmars.com changed:

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





Fixed dmd 1.021 and 2.004


-- 
Sep 28 2007