This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/52595] New: Incorrect parsing of commas in non-static data member initializers


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52595

             Bug #: 52595
           Summary: Incorrect parsing of commas in non-static data member
                    initializers
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: jeremy@jeremyms.com


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)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]