www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2960] New: CTFE rejects static array to dynamic array casts

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

           Summary: CTFE rejects static array to dynamic array casts
           Product: D
           Version: 1.043
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: patch, rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: kamm-removethis incasoftware.de


Test case:

char[] foo(char[] source) { return ""; }
const v = "bar";
const r = foo(v);

Result:
Error: cannot evaluate foo(cast(char[])v) at compile time

This works in D2 because of changes to Cast in constfold.c. LDC backported the
changes by adding this code from the D2 frontend:

    if (e1->op == TOKstring)
    {
    if (tb->ty == Tarray && typeb->ty == Tarray &&
        tb->nextOf()->size() == typeb->nextOf()->size())
    {
        return expType(to, e1);
    }
    }

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 10 2009
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2960


Walter Bright <bugzilla digitalmars.com> changed:

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





13:28:38 PDT ---
Fixed dmd 1.047

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