2 ms·
Linus has long railed against the aspects of the C standard, and how they're been interpreted by compiler writers [0]. I'm not much of a C programmer, but the
by simonbyrne 8y ago
Linus has long railed against the aspects of the C standard, and how they're been interpreted by compiler writers [0].
I'm not much of a C programmer, but the C aliasing rules are incredibly confusing, and seem to be interpreted differently by GCC and Clang. e.g. GCC allows type punning via unions[1], but Clang does not [2].
[0] https://www.cl.cam.ac.uk/~srk31/research/papers/kell17some-preprint.pdf https://www.cl.cam.ac.uk/~srk31/research/papers/kell17some-p...
[1] https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#Type-punning https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#Typ...
[2] https://bugs.llvm.org/show_bug.cgi?id=31928 https://bugs.llvm.org/show_bug.cgi?id=31928
- ajross 8y agoThat was just a clang bug, and as I read the comments they fixed it quietly without exactly admitting as much. That kind of local bitsmithery on floating point values is a pervasive idiom, clearly explained by the syntax of the language, and the compiler had no business getting smart with it.
- flamedoge 8y agounion and memcpy are known ways to do type-punning. Caveat to these is that they require at least one memory copy operation. Last I heard, clang and llvm's TBAA is still buggy.