4 ms·
No, the C standard defines it as I had specified: > If the member used to read the contents of a union object is not the same as the member last used to store
by saagarjha 6y ago
No, the C standard defines it as I had specified:
> 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.
This verbiage has existed in a footnote of the standard since a defect report was filed against C99: http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_283.htm http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_283.htm. This happens to be one of the few instances where Linus is right about the C standard, but without knowing why ;)
- quietbritishjim 6y agoYep, you're right, my mistake