I have some legacy code that I'm building with "newer" compilers and running into some static const double initialization errors that don't make sense to me. Here's what I have:
//header.h
class myclass
{
private:
static const double foo = 3.1415;
static const double bar = 12345.0 * foo;
};
When compiling this code with gcc version 4.3.3 - I am seeing the following error:
foo cannot appear in a constant-expression
I've already debunked this as not being static initialization order fiasco, as I believe intrinsic data types have a well defined order of initialization - especially when they live in the same class. As a test I've already tried to static_cast< double >
the expression, but that produces yet another error stating that only integral type casts are allowed in a const expression.