[llvm-commits] [PATCH] Fix Alias Bug

dag at cray.com dag at cray.com
Tue Jan 8 14:59:53 PST 2013


Stephen Canon <scanon at apple.com> writes:

> For C, footnote 95 says the following:
>
>     
>     If the member used to read the contents of a union object
>     
>     is not the same as the member last used to store a value
>     
>     in the object, the appropriate part of the object representation
>     
>     of the value is reinterpreted as an object representation in the
>     
>     new type as described in 6.2.6 (a process sometimes called
>     
>     ‘‘type punning’’). This might be a trap representation. 

I believe the C standard has also changed over the years, to the point
where there's much confusion about this issue, according to the google.
:)

> I am not aware of any similar language for C++, though I don't know
> the C++ standard nearly as well.  Either way, memcpy( ) is
> unambiguously correct and should generate good code.

I'm happy to use memcpy if that's what people want.  Honestly, my goal
was to make gcc shut up, not necessarily guarantee correctness, though
this is a unit test.  :)

                         -David




More information about the llvm-commits mailing list