This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/49896] undefined reference to static const integral member whose address is not used, for some values of the constant
- From: "harald at gigawatt dot nl" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 29 Jul 2011 17:55:40 +0000
- Subject: [Bug c++/49896] undefined reference to static const integral member whose address is not used, for some values of the constant
- Auto-submitted: auto-generated
- References: <bug-49896-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49896
Harald van Dijk <harald at gigawatt dot nl> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |harald at gigawatt dot nl
--- Comment #4 from Harald van Dijk <harald at gigawatt dot nl> 2011-07-29 17:55:21 UTC ---
0x80000000 is (possibly wrongly) rejected as an integer constant expression,
because it is not within int's range. It is accepted with an explicit cast.
With a slight modification, it triggers an ICE:
template<class C>
class test {
protected:
static const int versionConst = 0x80000000;
enum { versionEnum = versionConst };
public:
int getVersion();
};
template<class C>
int test<C>::getVersion() {
return versionEnum;
}
class dummy_class {};
int main() {
test<dummy_class> t;
return t.getVersion();
}
$ g++ -c test.cc
test.cc: In instantiation of âtest<dummy_class>â:
test.cc:18:21: instantiated from here
test.cc:5:8: error: the value of âtest<dummy_class>::versionConstâ is not
usable in a constant expression
test.cc:5:8: internal compiler error: in non_const_var_error, at
cp/semantics.c:6852
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.6.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /var/tmp/pkgbuild/sys-devel/gcc-4.6.1/work/gcc-4.6.1/configure
--build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --prefix=/usr
--enable-languages=c,c++,ada --enable-checking
Thread model: posix
gcc version 4.6.1 (GCC)