With this example: --- template <class T, int N> struct A { static int foo(); }; template <class T, int N> struct B { int var = A<T,N>::foo(); }; --- Compiled with -std=gnu++11, g++ gives the following error: test.cpp:9:17: error: expected ';' at end of member declaration test.cpp:9:17: error: declaration of 'int B<T, N>::N' test.cpp:7:20: error: shadows template parm 'int N' test.cpp:9:18: error: expected unqualified-id before '>' token test.cpp:9:15: error: wrong number of template arguments (1, should be 2) test.cpp:2:8: error: provided for 'template<class T, int N> struct A' Surrounding the initializer in parentheses, i.e. int var = (A<T,N>::foo()); fixes the error. This error also does not happen for static data members. It appears that g++ is not properly parsing the comma inside the template argument list. COLLECT_GCC=g++-4.7.0-pre9999 COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.7.0-pre9999/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /var/tmp/portage/sys-devel/gcc-4.7.0_pre9999/work/gcc-4.7.0-9999/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.7.0-pre9999 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.0-pre9999/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.7.0-pre9999 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.7.0-pre9999/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.7.0-pre9999/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.0-pre9999/include/g++-v4 --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --disable-fixed-point --without-ppl --without-cloog --enable-lto --disable-nls --with-system-zlib --disable-werror --enable-secureplt --enable-multilib --with-multilib-list=m32,m64 --enable-libmudflap --disable-libssp --enable-libgomp --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.7.0-pre9999/python --enable-checking=release --disable-libgcj --enable-languages=c,c++,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-targets=all --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.7.0_pre9999' Thread model: posix gcc version 4.7.0-pre9999 20120314 (prerelease) commit fe9f13b8d6563daf45c0ed10da40ec2c05473a11 (Gentoo 4.7.0_pre9999)
See C++ defect report 325, it says it applies to NSDMI also.
http://open-std.org/JTC1/SC22/WG21/docs/cwg_active.html#325 for future reference.
I'm a bit confused here. If this is Core/325 should be duplicate of PR51666, right? But, maybe too quickly, I closed the latter as fixed upon Jason commit (see also http://gcc.gnu.org/ml/gcc-patches/2012-01/msg00062.html). So, what's going on? Was the commit for PR51666 incomplete, so to speak?
(In reply to comment #3) > So, what's going on? Was the commit for PR51666 incomplete, so to speak? Maybe it was incomplete but then again the Defect report is still open though there has been some changes to the dr about the change and such.
*** Bug 61290 has been marked as a duplicate of this bug. ***
*** Bug 61690 has been marked as a duplicate of this bug. ***
*** Bug 65110 has been marked as a duplicate of this bug. ***
*** Bug 65514 has been marked as a duplicate of this bug. ***
*** Bug 66344 has been marked as a duplicate of this bug. ***
Author: nathan Date: Fri Jun 5 13:35:30 2015 New Revision: 224152 URL: https://gcc.gnu.org/viewcvs?rev=224152&root=gcc&view=rev Log: cp/ PR c++/52595 * parser.c (cp_parser_cache_defarg): Continue looking for declarators when scanning a potential template argument list of an NSDMI. testsuite/ PR c++/52595 * g++,dg/cpp0x/nsdmi-defer5.C: Add template case. Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/parser.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/g++.dg/cpp0x/nsdmi-defer5.C
patch committed https://gcc.gnu.org/ml/gcc-patches/2015-05/msg02582.html
*** Bug 66961 has been marked as a duplicate of this bug. ***
*** Bug 69809 has been marked as a duplicate of this bug. ***
*** Bug 78011 has been marked as a duplicate of this bug. ***
*** Bug 80890 has been marked as a duplicate of this bug. ***