Holy crap, clang in C++ mode is *evil*!
https://godbolt.org/z/hM7W1WPsE
gcc at least puts a `ud2` in there...
Holy crap, clang in C++ mode is *evil*!
https://godbolt.org/z/hM7W1WPsE
gcc at least puts a `ud2` in there...
@lina in c++26 mode too?
@lina eh. Is it really evil? The code invokes nasal demons, so anything goes. The language on the other hand…
@JSMuellerRoemer @lina I really don't understand this attitude. I'm getting the feeling that some compiler people read the C/C++ standards like the devil reads the bible.
@andreas @JSMuellerRoemer I learned today that, technically, the C standard can be interpreted as to make all kinds of valid code UB, because it defines "anything it doesn't define" as UB. And GCC exploits this in at least one case.
So unfortunately the "if the code is UB the compiler can legitimately do whatever it wants" argument doesn't really work, because a compiler that maximally exploits UB would be completely unusable for compiling any real program.
@lina
Jason Turner covered this scenario in one of his weekly videos: https://youtu.be/atEP9wbuaL0?t=130