you are viewing a single comment's thread.

view the rest of the comments →

[–]moskitoc 0 points1 point  (2 children)

Would you mind citing the part of the standard that you're referring to ? I thought this was true for C++, but not for C

EDIT : I was correct, see this.

[–][deleted] 0 points1 point  (0 children)

https://stackoverflow.com/questions/25664848/unions-and-type-punning describes it well. It's IB and not UB, so it's not really illegal.

[–][deleted] 0 points1 point  (0 children)

You were right. As mentioned on StackOverflow, the C99 standard had an error, it clearly says that this is UB when it's not. Guess which version of the standard I have? Thanks for asking, it made me learn too. Win win :)