The real fix is to not use -ffast-math. It breaks all sorts of things by design.
If you really want to relax the correctness of your code to get some potential speedup, either do the optimizations yourself instead of letting the compiler do them, or locally enable fast-math equivalents.
As for the is constant expression GCC extensions, that stuff is natively available in standard C++ nowadays.