Boost logo

Boost :

From: Proton (matt_at_[hidden])
Date: 2022-08-22 00:11:43

> Hi Matt,
> I haven't tried whether clang's bit_cast supports bit fields. There is a problem with your simple implementation:
> Memory size for long double/float80 can be 10/12/16 bytes depending on platform or compiler option. You didn't take that into account, so bit_cast then fails.
> That's why I'm working on extended structures for the bitrepresentation for float-types, so that unusual or machine-specific types can also be mapped. These then also include manipulating the individual components and/or checking for special values. For the concrete implementations it would be advantageous to have a stable bit_cast; otherwise I can only use explicit bitpatterns and hope they are (ieee) compatible.
> This approach has other advantages. These extended structures always deliver correct results, even if the compiler option fast-math/finite-math or something similar is set. This can be used to implement various requirements, e.g. isnan/isinf:
> - isnan/isinf -> default
> - isnan_stable/isinf_stable -> correct results also with fast/finite-math etc
> This can be very useful when implementing math functions.
> Best, Gero


What platform does this fail on? I have provided multiple macro enabled definitions for the bit patterns of long doubles on major architectures.

Have you run into issues with the implementations of isnan or isinf? We provide a version of fpclassify ( that yields stable results regardless of the compiler flag like you are looking for.


Boost list run by bdawes at, gregod at, cpdaniel at, john at