www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6844] New: Reinterpret cast of static to dynamic array doesn't work in safe code

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

           Summary: Reinterpret cast of static to dynamic array doesn't
                    work in safe code
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: pszturmaj tlen.pl



---
void main()  safe
{
    long[2] a;
    auto b = cast(ubyte[])a; // error
    auto c = cast(ubyte[])cast(long[])a; // works
}

main.d(4): Error: cast from long[2u] to ubyte[] not allowed in safe code

Without  safe mode there's no error.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 23 2011
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6844


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |yebblies gmail.com
         Resolution|                            |DUPLICATE



Slicing a static array is equivalent to taking the address of a local variable,
which is illegal in safed.  The second case works due to bug 8838.

*** This issue has been marked as a duplicate of issue 8838 ***

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