User account creation filtered due to spam.

Bug 18140 - [3.4/4.0 regression] C++ parser bug when using >> in templates
Summary: [3.4/4.0 regression] C++ parser bug when using >> in templates
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.1
: P2 normal
Target Milestone: 3.4.3
Assignee: Mark Mitchell
Keywords: rejects-valid
Depends on:
Reported: 2004-10-25 09:42 UTC by Markus F.X.J. Oberhumer
Modified: 2004-10-28 05:28 UTC (History)
1 user (show)

See Also:
Known to work: 3.3.4
Known to fail: 3.4.3 4.0.0
Last reconfirmed: 2004-10-25 11:45:05


Note You need to log in before you can comment on or make changes to this bug.
Description Markus F.X.J. Oberhumer 2004-10-25 09:42:51 UTC
gcc incorrectly rejects the following template code - seems to be a bug in the
new (gcc 3.4) C++ parser.

> g++-4.0 -Wall -W x.cpp
x.cpp:6: error: spurious '>>', use '>' to terminate a template argument list
x.cpp:6: error: expected primary-expression before "S"
x.cpp:6: error: expected %<;%> before "S"

template <int N> struct IntHolder {
    static const int value = N;

template <int N, int S> struct ShrIntHolder {
    static const int value = IntHolder< N>>S >::value;
Comment 1 Wolfgang Bangerth 2004-10-25 11:31:25 UTC
Confirmed, a regression in 3.4 and mainline. 
Comment 2 Andrew Pinski 2004-10-25 11:45:03 UTC
Looks like caused by the new parser
: Search converges between 2003-12-18-trunk (#431) and 2003-12-24-trunk (#432).
Comment 3 CVS Commits 2004-10-28 05:17:21 UTC
Subject: Bug 18140

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	2004-10-28 05:17:15

Modified files:
	gcc/cp         : ChangeLog parser.c call.c 
	gcc/testsuite  : ChangeLog 
	gcc/testsuite/g++.dg/template: error10.C 
Added files:
	gcc/testsuite/g++.dg/template: shift1.C 
	gcc/testsuite/g++.dg/init: ref12.C 

Log message:
	PR c++/17435
	* call.c (convert_like_real): Fix formatting.
	(initialize_reference): When binding a temporary to a base class,
	ensure that the nominal copy made is to the derived class, not the
	base class.
	PR c++/18140
	* parser.c (cp_parser_next_token_ends_template_argument_p): Do not
	include ">>".
	PR c++/17435
	* g++.dg/init/ref12.C: New test.
	PR c++/18140
	* g++.dg/template/shift1.C: New test.
	* g++.dg/template/error10.C: Adjust error markers.


Comment 5 Mark Mitchell 2004-10-28 05:28:45 UTC
Fixed in GCC 3.4.3.