cast oddities - void* <-> AA

David Nadlinger see at klickverbot.at
Sat Aug 18 09:58:22 PDT 2012


On Friday, 17 August 2012 at 22:15:10 UTC, Iain Buclaw wrote:
> 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;
> }

I also once encountered some cases where the DMD frontend would 
allow conversions between structs and scalar types or other 
unrelated structs which happened to have the same member layout 
– which broke LDC, as the LLVM IR is typed.

David


More information about the Digitalmars-d mailing list