www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15672] New: Casting from void[] to T[] is erroneously


          Issue ID: 15672
           Summary: Casting from void[] to T[] is erroneously considered
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dhasenan gmail.com

void main()  safe {
    int*[] a = [new int];
    void[] b = cast(void[])a;
    size_t[] c = cast(size_t[])b;
    c[0] = 0;
    *(a[0]) = 0;  // Segmentation fault

If it were only allowed to cast to immutable(T)[] from void[], that would be

Thanks to iakh for the test case.

Feb 10 2016