4 ms·
What you are describing is unspecified and implementation-defined behavior [0]. Avoiding UB (edit: in general) doesn't have anything to do with the code being
by protomolecule 4y ago
What you are describing is unspecified and implementation-defined behavior [0].
Avoiding UB (edit: in general) doesn't have anything to do with the code being portable and everything with the code not being buggy [1][2].
[0] https://en.cppreference.com/w/c/language/behavior https://en.cppreference.com/w/c/language/behavior
[1] https://blog.regehr.org/archives/213 https://blog.regehr.org/archives/213
[2] http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html http://blog.llvm.org/2011/05/what-every-c-programmer-should-...
- legalcorrection 4y agoOh really? Then why does every compiler I use have a parameter to turn off strict aliasing? You cite to a source that contradicts you. In the llvm blog post: "It is also worth pointing out that both Clang and GCC nail down a few behaviors that the C standard leaves undefined."
- protomolecule 4y agoSometimes a compiler gives a guarantee that a particular UB is always handled in a specific way, but you cannot generalize this to all UB. Added 'in general' to my comment to make this explicit.