Language features and reinterpret casts

Jesse Phillips jessekphillips+D at gmail.com
Mon Sep 20 18:21:53 PDT 2010


bearophile Wrote:

> - C Standard says that assigning to one member of a union and then accessing a different member is undefined behaviour.
> - GCC is a practical compiler, so it has the -fno-strict-aliasing switch, that allows to use that trick. See "-Wstrict-aliasing" and:
> http://stackoverflow.com/questions/2906365/gcc-strict-aliasing-and-casting-through-a-union
> - Walter said that regarding such union semantics D acts as C. So that union trick will break with other future D compilers.

I believe that defined behavior within an area where C is specified to be undefined is completely in line with operating as C does. But where does Walter say Unions act as C in this case? Why not, define the behavior and leave it.


More information about the Digitalmars-d mailing list