Comment by hddqsb
3 years ago
It should be noted that in this particular case it only happens when optimisations are enabled (-O2).
With -O2: https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(filename...
Without -O2: https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(filename...
[Edited. I originally wrote "It should be noted that this only happens when..." but inserted "in this particular case" after @eru pointed it out.]
In this particular case, yes. You can't rely -O0 to save your bacon in general.
Usually most UB only shows up when optimizations are turned on.