2 ms·
GCC explicitly states znd documents that type punning through unions will work as expected. This doesn't work by accident. It works very explicitly by design of
by rocqua 5y ago
GCC explicitly states znd documents that type punning through unions will work as expected.
This doesn't work by accident. It works very explicitly by design of GCC.
Different GCC versions aren't randomly going to change documented behavior. And when they accidentally do, they will consider it a bug.
- comex 5y agoRegardless, type punning though a union is not undefined behavior in C the first place [1] [2]. On the other hand, it is undefined in C++, but GCC allows it there too. [1] https://stackoverflow.com/questions/11639947/is-type-punning-through-a-union-unspecified-in-c99-and-has-it-become-specified https://stackoverflow.com/questions/11639947/is-type-punning... [2] https://stackoverflow.com/questions/25664848/unions-and-type-punning https://stackoverflow.com/questions/25664848/unions-and-type...