Bug 57771 - g++ misinterprets >> in static_cast
Summary: g++ misinterprets >> in static_cast
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.8.1
: P3 normal
Target Milestone: 4.8.2
Assignee: Jakub Jelinek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-01 19:57 UTC by Hristo Venev
Modified: 2013-07-03 20:29 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2013-07-01 00:00:00


Attachments
gcc49-pr57771.patch (693 bytes, patch)
2013-07-01 20:56 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Hristo Venev 2013-07-01 19:57:06 UTC
template<int a>
struct s{};
s<static_cast<int>(4>>2)> x;

This works in C++98 mode but fails in C++11 mode.
Maybe g++ misunderstands >> as closing angle brackets, but this does not make sense because they are in (). clang++ compiles this code. This looks like bug 37875 but for casts.
Comment 1 Jakub Jelinek 2013-07-01 20:56:18 UTC
Created attachment 30416 [details]
gcc49-pr57771.patch

Untested fix.
Comment 2 Jakub Jelinek 2013-07-03 20:29:12 UTC
Author: jakub
Date: Wed Jul  3 20:20:30 2013
New Revision: 200647

URL: http://gcc.gnu.org/viewcvs?rev=200647&root=gcc&view=rev
Log:
	PR c++/57771
	* parser.c (cp_parser_postfix_expression) <case RID_STATCAST>
	Temporarily set parser->greater_than_is_operator_p for
	cp_parser_expression and restore from saved value afterwards.

	* g++.dg/template/arg9.C: New test.

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

Author: jakub
Date: Wed Jul  3 20:22:16 2013
New Revision: 200648

URL: http://gcc.gnu.org/viewcvs?rev=200648&root=gcc&view=rev
Log:
	PR c++/57771
	* parser.c (cp_parser_postfix_expression) <case RID_STATCAST>
	Temporarily set parser->greater_than_is_operator_p for
	cp_parser_expression and restore from saved value afterwards.

	* g++.dg/template/arg9.C: New test.

Added:
    branches/gcc-4_8-branch/gcc/testsuite/g++.dg/template/arg9.C
Modified:
    branches/gcc-4_8-branch/gcc/cp/ChangeLog
    branches/gcc-4_8-branch/gcc/cp/parser.c
    branches/gcc-4_8-branch/gcc/testsuite/ChangeLog