public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jeremy at jeremyms dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/52595] New: Incorrect parsing of commas in non-static data member initializers Date: Thu, 15 Mar 2012 18:53:00 -0000 [thread overview] Message-ID: <bug-52595-4@http.gcc.gnu.org/bugzilla/> (raw) 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)
next reply other threads:[~2012-03-15 18:47 UTC|newest] Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-03-15 18:53 jeremy at jeremyms dot com [this message] 2012-03-15 18:58 ` [Bug c++/52595] " pinskia at gcc dot gnu.org 2012-03-15 19:25 ` [Bug c++/52595] [DR 325] commas and non-static data member initializers don't mix pinskia at gcc dot gnu.org 2012-03-20 11:35 ` paolo.carlini at oracle dot com 2012-03-20 23:45 ` pinskia at gcc dot gnu.org 2014-05-23 11:09 ` redi at gcc dot gnu.org 2014-07-04 8:29 ` redi at gcc dot gnu.org 2015-02-18 19:30 ` redi at gcc dot gnu.org 2015-03-22 16:17 ` redi at gcc dot gnu.org 2015-05-27 23:05 ` nathan at gcc dot gnu.org 2015-05-30 16:04 ` redi at gcc dot gnu.org 2015-06-05 13:36 ` nathan at gcc dot gnu.org 2015-06-05 14:16 ` nathan at gcc dot gnu.org 2015-07-21 18:19 ` redi at gcc dot gnu.org 2015-07-21 18:20 ` redi at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-52595-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).