public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/58707] New: [C++11] A greater-than operator in square brackets should not end a template argument list
@ 2013-10-12 21:48 tuomas.tynkkynen at iki dot fi
  2013-10-15  8:52 ` [Bug c++/58707] " paolo.carlini at oracle dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: tuomas.tynkkynen at iki dot fi @ 2013-10-12 21:48 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/58707] [C++11] A greater-than operator in square brackets should not end a template argument list
  2013-10-12 21:48 [Bug c++/58707] New: [C++11] A greater-than operator in square brackets should not end a template argument list tuomas.tynkkynen at iki dot fi
@ 2013-10-15  8:52 ` paolo.carlini at oracle dot com
  2013-10-15 16:36 ` paolo at gcc dot gnu.org
  2013-10-15 16:37 ` paolo.carlini at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-10-15  8:52 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2013-10-15
           Assignee|unassigned at gcc dot gnu.org      |paolo.carlini at oracle dot com
   Target Milestone|---                         |4.9.0
     Ever confirmed|0                           |1

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Apparently just a missing parser->greater_than_is_operator_p dance


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/58707] [C++11] A greater-than operator in square brackets should not end a template argument list
  2013-10-12 21:48 [Bug c++/58707] New: [C++11] A greater-than operator in square brackets should not end a template argument list tuomas.tynkkynen at iki dot fi
  2013-10-15  8:52 ` [Bug c++/58707] " paolo.carlini at oracle dot com
@ 2013-10-15 16:36 ` paolo at gcc dot gnu.org
  2013-10-15 16:37 ` paolo.carlini at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: paolo at gcc dot gnu.org @ 2013-10-15 16:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> ---
Author: paolo
Date: Tue Oct 15 16:36:11 2013
New Revision: 203624

URL: http://gcc.gnu.org/viewcvs?rev=203624&root=gcc&view=rev
Log:
/cp
2013-10-15  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/58707
    * parser.c (cp_parser_postfix_open_square_expression): Set
    parser->greater_than_is_operator_p for the argument.

/testsuite
2013-10-15  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/58707
    * g++.dg/cpp0x/pr58707.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/pr58707.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/58707] [C++11] A greater-than operator in square brackets should not end a template argument list
  2013-10-12 21:48 [Bug c++/58707] New: [C++11] A greater-than operator in square brackets should not end a template argument list tuomas.tynkkynen at iki dot fi
  2013-10-15  8:52 ` [Bug c++/58707] " paolo.carlini at oracle dot com
  2013-10-15 16:36 ` paolo at gcc dot gnu.org
@ 2013-10-15 16:37 ` paolo.carlini at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-10-15 16:37 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED
           Assignee|paolo.carlini at oracle dot com    |unassigned at gcc dot gnu.org

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Fixed.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-10-15 16:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-12 21:48 [Bug c++/58707] New: [C++11] A greater-than operator in square brackets should not end a template argument list tuomas.tynkkynen at iki dot fi
2013-10-15  8:52 ` [Bug c++/58707] " paolo.carlini at oracle dot com
2013-10-15 16:36 ` paolo at gcc dot gnu.org
2013-10-15 16:37 ` paolo.carlini at oracle dot com

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).