5 ms·
In C you can store a value to a field of a union and then read from a different field. This is usually done to "get the byte representation of a float" or thin
by Tomte 11y ago
In C you can store a value to a field of a union and then read from a different field.
This is usually done to "get the byte representation of a float" or things like that.
Except... it's undefined behavior.
- kerny 11y ago> Except... it's undefined behavior. No longer true since C99.
- sinistersnare 11y agoSource please? Or do I need money to get a copy of the standard?
- kzrdude 11y agoGet publicly available draft 1570 of the C11 standard from the committee: http://www.open-std.org/jtc1/sc22/wg14/www/standards.html http://www.open-std.org/jtc1/sc22/wg14/www/standards.html
- tibiapejagala 11y agoLatest standard drafts are usually free for C99 see http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf
- rylee 11y agohttps://news.ycombinator.com/item?id=9827417 https://news.ycombinator.com/item?id=9827417