https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65514
Bug ID: 65514 Summary: Initializing a non-static const data member of a template class from a static const data member of another template class results in errors in certain situations Product: gcc Version: 4.9.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: nilschrbrause at googlemail dot com Created attachment 35093 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35093&action=edit Test source % g++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: /build/gcc-multilib/src/gcc-4.9-20150304/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-cloog-backend=isl --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-multilib --disable-werror --enable-checking=release Thread model: posix gcc version 4.9.2 20150304 (prerelease) (GCC) % g++ -std=c++11 test.cpp test.cpp:12:25: error: expected ‘;’ at end of member declaration const int is = add<1, x>::is; ^ test.cpp:12:25: error: declaration of ‘const int add1<x>::x’ test.cpp:8:11: error: shadows template parm ‘int x’ template <int x> ^ test.cpp:12:26: error: expected unqualified-id before ‘>’ token const int is = add<1, x>::is; ^ test.cpp:12:22: error: wrong number of template arguments (1, should be 2) const int is = add<1, x>::is; ^ test.cpp:2:7: error: provided for ‘template<int x, int y> class add’ class add ^ Source code is attached. The error vanishes, when: - a 'static' is added: const static int is = add<1, x>::is; - the '1' and the 'x' are reversed: const int is = add<x, 1>::is; - the RHS is enclosed in paranthesis: const int is = (add<1, x>::is);