Comment by uecker Comment by uecker a day ago 2 replies Copy Link View on Hacker News Union type punning is allowed and supported by GCC: https://godbolt.org/z/vd7h6vf5q
Copy Link ryao a day ago Collapse Comment - I said that GCC defines type punning via unions. It is an extension to the C standard that GCC did.That said, using “the code compiles in godbolt” as proof that it is not relying on what the standard specifies to be UB is fallacious. Reply View | 1 reply Copy Link uecker a day ago Parent Collapse Comment - I am a member of the standards committee and a GCC maintainer. The C standard supports union punning. (You are right though that relying on godbolt examples can be misleading.) Reply View | 0 replies
Copy Link uecker a day ago Parent Collapse Comment - I am a member of the standards committee and a GCC maintainer. The C standard supports union punning. (You are right though that relying on godbolt examples can be misleading.) Reply View | 0 replies
I said that GCC defines type punning via unions. It is an extension to the C standard that GCC did.
That said, using “the code compiles in godbolt” as proof that it is not relying on what the standard specifies to be UB is fallacious.