This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/58707] New: [C++11] A greater-than operator in square brackets should not end a template argument list
- From: "tuomas.tynkkynen at iki dot fi" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 12 Oct 2013 21:48:29 +0000
- Subject: [Bug c++/58707] New: [C++11] A greater-than operator in square brackets should not end a template argument list
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58707
Bug ID: 58707
Summary: [C++11] A greater-than operator in square brackets
should not end a template argument list
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: tuomas.tynkkynen at iki dot fi
Created attachment 30993
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30993&action=edit
The failing code snippet
The following code snippet does not compile on latest GCC trunk:
template<int i> class TC { };
constexpr int foo[] = { 42, };
TC<foo[0 > 1]> bar;
Actual result:
tmtynkky@e42-7:/tmp$ /dos/gcc-trunk/bin/gcc -xc++ -std=c++11 -pedantic -c -o
/dev/null bracket.cpp
bracket.cpp:3:10: error: template argument 1 is invalid
TC<foo[0 > 1]> bar;
^
bracket.cpp:3:12: error: expected unqualified-id before numeric constant
TC<foo[0 > 1]> bar;
^
The '>' seems to get parsed as the ending delimiter of the template argument
list, even though it shouldn't since it is nested inside a pair of square
brackets. Clang++ 3.3 correctly accepts this snippet.
(originally discussed on
http://forum.cppgm.org/question/2286/inside-square-brackets-terminates-a-template-argument-list/)
Version information:
gcc version 4.9.0 20131011 (experimental) [trunk revision 203401] (GCC)
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-trunk-source/gcc/configure --enable
languages=c,c++,fortran --enable-checking=release --disable-libmudflap
--disable libstdcxx-pch --enable-libgomp --enable-lto --enable-gold
--with-plugin ld=/usr/bin/gold --with-cloog-include=/usr/include-cloog
--with-cloog lib=/usr/lib64 --prefix=/usr/local/gcc-trunk