[Issue 6792] New: [CTFE] ICE with pointer cast of indexed array

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Oct 10 01:16:15 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=6792

           Summary: [CTFE] ICE with pointer cast of indexed array
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: youxkei at gmail.com
                CC: clugdbug at yahoo.com.au



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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug at yahoo.com.au
            Summary|[CTFE] "CTFE internal       |[CTFE] ICE with pointer
                   |error" occurs               |cast of indexed array


--- Comment #0 from Hisayuki Mima <youxkei at gmail.com> 2011-10-08 10:24:56 PDT ---
struct S{
    int i;
}

static assert({
    {
        void* p;
        p = [S(1)].ptr;
        S s = *(cast(S*)p);// OK
        assert(s.i == 1);
    }
    {
        void*[] ary;
        ary ~= [S(2)].ptr;
        S s = *(cast(S*)ary[0]);// Error: CTFE internal error assigning struct
        assert(s.i == 2);
    }
    {
        void*[string] aa;
        aa["key"] = [S(3)].ptr;
        S s = *(cast(S*)aa["key"]);// Error: CTFE internal error assigning
struct
        assert(s.i == 3);
    }
    return true;
}());


The latest dmd built from github cannot compile the above code.

--- Comment #1 from Don <clugdbug at yahoo.com.au> 2011-10-10 01:15:26 PDT ---
Another case, where it's an lvalue instead of an rvalue:

    {
        void*[7] ary;
        ary[6]= [S(2)].ptr;        
        *(cast(S*)ary[6]) = S(4); //ICE(interpret.c 2965)
    }

The root cause is that type painting of pointers hasn't been considered
properly in CTFE.

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


More information about the Digitalmars-d-bugs mailing list