I'm running into a curious bug when I assign values to long double
variable types. (PowerPC architecture, gcc v4.9.2)
Specifically:
const constexpr long double DEGREE_TO_RAD = 0.0174532925199432954743716805978693;
const constexpr long double RAD_TO_DEGREE = 1. / DEGREE_TO_RAD;
seems to result in the following compiler error:
error: ‘(1.0e+0l / 1.74532925199432954743716805978693e-2l)’ is not a constant expression
const constexpr long double RAD_TO_DEGREE = 1. / DEGREE_TO_RAD;
I am not an expert in C++; this is software I'm attempting to build specifically for my development machine's environment. However, my research has led me to the following tidbit:
On some PowerPC and SPARCv9 machines,
long double
is implemented as a double-double arithmetic, where along double
value is regarded as the exact sum of two double-precision values, giving at least a 106-bit precision; with such a format, thelong double
type does not conform to the IEEE floating-point standard. Otherwise,long double
is simply a synonym fordouble
(double precision). [wiki]
Which leads me to believe the build failure is due to long double having a different interpretation in my architecture vs the standard x86. Changing long double
to double
in the source allows the compilation to succeed. Is this a coincidence? Why would g++ throw a fit about it in this instance?