| |
| ▲ | ryao a day ago | parent [-] | | According to another comment, the C standard contradicts the C standard on this: https://news.ycombinator.com/item?id=43794268 Taking snippets of the C standard out of context of the whole seems to result in misunderstandings on this. | | |
| ▲ | trealira a day ago | parent [-] | | It doesn't. That commenter is saying that in C99, it was unspecified behavior. Since C11 onward, it's been removed from the unspecified behavior annex and type punning is allowed, though it may generate a trap/non-value representation. It was never undefined behavior, which is different. Edit: no, it's still in the unspecified behavior annex, that's my mistake. It's still not undefined, though. | | |
| ▲ | ryao a day ago | parent [-] | | Most of the C code I write is C99 code, so it is undefined behavior either way for me (if I care about compilers other than GCC and Clang). That said, I am going to defer to the GCC developers on this since I do not have time to make sense of all versions of the C standard. | | |
| ▲ | trealira a day ago | parent [-] | | That's fair. In the end, what matters is how C is implemented in practice on the platforms your code targets, not what the C standard says. |
|
|
|
|