[cfe-dev] error: initialized if it is a static const integral data member
Rene Rebe
rene at exactcode.de
Fri Feb 19 07:50:14 PST 2010
Hi all,
still getting some production code to compile the next error is:
test.cc:5:26: error: in-class initializer has non-integral, non-enumeration type 'double'
While the type is a double in this case. This is tested in the clang testsuite:
test/SemaTemplate/instantiate-static-var.cpp
template<typename T>
class Y {
static const T value = 0; // expected-error{{'value' can only be initialized if it is a static const integral data member}}
};
Y<float> fy; // expected-note{{in instantiation of template class 'class Y<float>' requested here}}
G++ (even 4.4) does not even warn about this on neither -Wall, nor -Wextra, only with -pedantic. I assume due to this other POD initialization, especially of FP types will occur in quite some shipping code and thus suggest making it a warning, likewise.
René
--
René Rebe, ExactCODE GmbH, Jaegerstr. 67, DE-10117 Berlin
http://exactcode.com | http://t2-project.org | http://rene.rebe.name
More information about the cfe-dev
mailing list