[Issue 6374] New: [CTFE] Cannot subscript using pointer to array

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jul 24 14:05:08 PDT 2011


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

           Summary: [CTFE] Cannot subscript using pointer to array
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Mac OS X
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: kennytm at gmail.com


--- Comment #0 from kennytm at gmail.com 2011-07-24 14:05:05 PDT ---
Test case:

---------------------
static assert({
    int[] arr = [1];
    arr.ptr[0] = 2;   // <-- line 3
    return arr[0];
}() == 2);
---------------------
y.d(3): Error: cannot determine length of cast(int*)arr at compile time
y.d(5): Error: cannot evaluate delegate pure nothrow int()
{
int[] arr = [1];
(cast(int*)arr)[0u] = 2;
return arr[0u];
}
() at compile time
y.d(1): Error: static assert  (delegate pure nothrow int()
{
int[] arr = [1];
(cast(int*)arr)[0u] = 2;
return arr[0u];
}
() == 2) is not evaluatable at compile time
---------------------

Slicing is OK, though.

-- 
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