cast oddities - void* <-> AA

Iain Buclaw ibuclaw at ubuntu.com
Fri Aug 17 15:15:08 PDT 2012


Discovered this through some other issue when finishing up the 
latest frontend merge.


In the following example, I feel that this should not compile at 
all.

void main()
{
   int[int] a;
   void* b = cast(void*)a;
}


Given that the definition of an AA is (as defined in rt.aaA):

struct AA
{
     void* a;
}


Similarly for this code:

void main()
{
   int[int] a;
   void* b;
   a = cast(int[int]) b;   // fails
   a = cast(int[int]) &b;  // works
}

Correct me if I'm wrong, but both examples should warrant bug 
reports.


NB: These examples don't compile on GDC because of the safe 
guards from directly converting between scalar and pointer types.


Regards
Iain


More information about the Digitalmars-d mailing list