www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6092] New: Can't cast primitive to same-sized static array


           Summary: Can't cast primitive to same-sized static array
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: cbkbbejeap mailinator.com

--- Comment #0 from Nick Sabalausky <cbkbbejeap mailinator.com> 2011-06-02
13:38:32 PDT ---
This works, and is a very useful trick:

struct Foo {uint f;}
void main(){
    Foo a;
    ubyte[] b = cast(ubyte[4])a;

However, the following generates an error:

void main(){
    uint a;
    ubyte[] b = cast(ubyte[4])a;

The error:
Error: e2ir: cannot cast a of type uint to type ubyte[4u]

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