3 ms·
> aggressive ["]optimization[" ...] exploiting undefined behavior That's still a compiler bug. But yes, this is a bug in GCC and the title should show that.
by a1369209993 7y ago
> aggressive ["]optimization[" ...] exploiting undefined behavior
That's still a compiler bug.
But yes, this is a bug in GCC and the title should show that.
- saagarjha 7y agoExploiting undefined behavior is something compilers can and will do; that's not a bug. (Specifically, if a compiler can choose to omit code where it can prove that going down that branch would lead to undefined behavior. That's not what happened here.)
- paulddraper 7y agoTo be clear, it's a bug for code to exploit undefined behavior. A compiler may exploit the assumption that source code does not invoke undefined behavior.
- Skunkleton 7y agoComparing a pointer to null isn't UB. De-referencing invalid pointers is ub.