We do this all over LLVM (originated in the Object library): https://github.com/llvm-mirror/llvm/blob/master/include/llvm/Support/Endian.h … This is technically UB, but it's done in a way that compilers agree will work (via memcpy). Personally I would prefer a language feature that makes this implementable in the library without UB.
-
-
This Tweet is unavailable.
-
I feel like the only people being snotty here are the ones criticising the compiler vendor who is implementing an international standard.
- Show replies
-
-
-
No, for two reasons. The UB that this relies on only exists in C++ and the primary Clang maintainer has a committee paper which will make things like it not UB. The LLVM project provides lots of tools for helping developers find and fix UB. Nobody is trying to break your code.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.