https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118038
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #12 from Jakub Jelinek <jakub at gcc dot gnu.org> --- This isn't an internal compiler thing. Rather, in some formats not all bit patterns are valid, and turning the invalid bit pattern into floating type is undefined behavior. For bit_cast used outside of constant expression just UB at runtime, so your program can crash, raise exceptions etc., but in constant expressions such cases are required to be errors. The IEEE 754 single/double formats (so std::float32_t, std::float64_t or on most arches also float/double) don't have such cases, all the bit patterns result in valid numbers. The Intel Extended or IBM double double formats do have them, as has been mentioned, the various unnormal/pseudo NaNs/infinities are considered UB, IBM double double has e.g. the requirement that the resulting number is the sum of both doubles, but that the first double should have the result cast to double. So, if e.g. the second double is larger in magnitude than the first one (or even not smaller in magnitude by at least precision of double), then it is UB as well. Such bit_casts aren't valid in constant expressions. And on top of that, GCC bug unlikely to be fixed any time soon, we represent internally IBM double double just as a 106 bit precision number, so representing the variable precision of the weirdly defined format is not possible and so some in theory valid numbers aren't representable in constant expressions either (and rejected because of that).