My first UB causing g++ and clang++ to take different code paths leading to clang++ causing segfault.

Hahaha, not at all. Why is that? because the C and C++ standards are out of touch with how modern hardware works. I know that for example, on an x64 machine, pointers are simply integers, and arithmetic on those pointers should behave exactly like you would expect. Your example doesn't even make sense because arithmetic on NaN always yields NaN. More importantly, if you are a systems programmer, having a compiler that doesn't make silly assumptions simply because that standard says so is important. Having a compiler that allows you do to things that a well defined on your target system without screwing you over at every chance it gets is huge. There is a very good reason that things like the Linux kernel are compiled with -fno-strict-aliasing, and it is because the standard has created a set of silly rules that make it very hard to do low level systems programming sanely. In a system programming language, I should be able whatever makes natural sense for my target, and more importantly I should also be able to do things like bit twiddling and reinterpretation as much as I want/need. I shouldn't have to worry about a hostile compiler breaking my low level code because of some arcane rules that the committee has created.

/r/cpp Thread Parent Link - github.com