public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/33744] New: > within function-style cast incorrectly parsed as closing template angle bracket
@ 2007-10-12 3:10 mdorey at bluearc dot com
2007-10-12 12:52 ` [Bug c++/33744] function-style cast not allowed in template argument bangerth at dealii dot org
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: mdorey at bluearc dot com @ 2007-10-12 3:10 UTC (permalink / raw)
To: gcc-bugs
This compiled with 3.3:
template <bool cond>
struct A {
};
A< bool (2 > 1) > x;
It doesn't compile with at least some later versions, including 3.4 and 4.2.1,
with:
x.cpp:4: error: template argument 1 is invalid
x.cpp:4: error: invalid type in declaration before ';' token
Rejects-valid regression in the new parser in 3.4?
--
Summary: > within function-style cast incorrectly parsed as
closing template angle bracket
Product: gcc
Version: 4.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: mdorey at bluearc dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33744
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/33744] function-style cast not allowed in template argument
2007-10-12 3:10 [Bug c++/33744] New: > within function-style cast incorrectly parsed as closing template angle bracket mdorey at bluearc dot com
@ 2007-10-12 12:52 ` bangerth at dealii dot org
2007-10-12 13:05 ` bangerth at dealii dot org
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: bangerth at dealii dot org @ 2007-10-12 12:52 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from bangerth at dealii dot org 2007-10-12 12:52 -------
It's not the parentheses or the greater-than sign, but the cast
that triggers the error. I will have to look up whether a cast
is allowed here. For reference, icc accepts the code.
W.
--
bangerth at dealii dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|> within function-style cast|function-style cast not
|incorrectly parsed as |allowed in template argument
|closing template angle |
|bracket |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33744
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/33744] function-style cast not allowed in template argument
2007-10-12 3:10 [Bug c++/33744] New: > within function-style cast incorrectly parsed as closing template angle bracket mdorey at bluearc dot com
2007-10-12 12:52 ` [Bug c++/33744] function-style cast not allowed in template argument bangerth at dealii dot org
@ 2007-10-12 13:05 ` bangerth at dealii dot org
2007-10-12 13:19 ` mdorey at bluearc dot com
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: bangerth at dealii dot org @ 2007-10-12 13:05 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from bangerth at dealii dot org 2007-10-12 13:04 -------
The rule for template non-type arguments of integral type is 14.3.2/1:
1 A template-argument for a non-type, non-template template-parameter
shall be one of:
-- an integral constant-expression of integral or enumeration type;
...
Integral constant-expressions are dealt with in 5.19/1:
An integral constant-expression can involve only literals
(_lex.literal_), enumerators, const variables or static data members
of integral or enumeration types initialized with constant expressions
(_dcl.init_), non-type template parameters of integral or enumeration
types, and sizeof expressions. Floating literals (_lex.fcon_) can
appear only if they are cast to integral or enumeration types. Only
type conversions to integral or enumeration types can be used. In
particular, except in sizeof expressions, functions, class objects,
pointers, or references shall not be used, and assignment, increment,
decrement, function-call, or comma operators shall not be used.
I do not know whether bool(1) is considered a function-call. Gcc rejects
it as a template argument. However, it does accept (bool)1.
W.
--
bangerth at dealii dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bangerth at dealii dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33744
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/33744] function-style cast not allowed in template argument
2007-10-12 3:10 [Bug c++/33744] New: > within function-style cast incorrectly parsed as closing template angle bracket mdorey at bluearc dot com
2007-10-12 12:52 ` [Bug c++/33744] function-style cast not allowed in template argument bangerth at dealii dot org
2007-10-12 13:05 ` bangerth at dealii dot org
@ 2007-10-12 13:19 ` mdorey at bluearc dot com
2007-10-12 15:21 ` [Bug c++/33744] [4.1/4.2/4.3 regression] function-style cast and '>' " bangerth at dealii dot org
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: mdorey at bluearc dot com @ 2007-10-12 13:19 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from mdorey at bluearc dot com 2007-10-12 13:19 -------
(I'm told that) these two function-style casts compile fine on 4.2.1:
template <bool cond>
struct A {
};
A<bool (2)> y;
A<bool (2 < 1)> z;
This is why I suggest the greater-than is a necessary part of the bug. Do you
have a counter-example, Wolfgang - where the greater-than sign isn't necessary
to cause the same failure?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33744
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/33744] [4.1/4.2/4.3 regression] function-style cast and '>' not allowed in template argument
2007-10-12 3:10 [Bug c++/33744] New: > within function-style cast incorrectly parsed as closing template angle bracket mdorey at bluearc dot com
` (2 preceding siblings ...)
2007-10-12 13:19 ` mdorey at bluearc dot com
@ 2007-10-12 15:21 ` bangerth at dealii dot org
2007-10-12 17:12 ` mdorey at bluearc dot com
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: bangerth at dealii dot org @ 2007-10-12 15:21 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from bangerth at dealii dot org 2007-10-12 15:21 -------
(In reply to comment #3)
> (I'm told that) these two function-style casts compile fine on 4.2.1:
>
> template <bool cond>
> struct A {
> };
>
> A<bool (2)> y;
> A<bool (2 < 1)> z;
Uh, indeed, I see. This is weird indeed. So in other words, these codes
compile:
------------------
template <bool> struct A {};
A<bool(1)> a;
A<bool(1<2)> b;
A<(bool)(1>2)> c;
------------------
but this one doesn't:
------------------
template <bool> struct A {};
A<bool(1>2)> b;
------------------
This is indeed very weird: it only fails with the function-style cast
and the greater-than sign...
Since this worked in gcc 3.3, this is a regression.
W.
--
bangerth at dealii dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Keywords| |rejects-valid
Known to fail| |4.1.2 4.2.0 4.3.0
Known to work| |3.3.6
Last reconfirmed|0000-00-00 00:00:00 |2007-10-12 15:21:49
date| |
Summary|function-style cast not |[4.1/4.2/4.3 regression]
|allowed in template argument|function-style cast and '>'
| |not allowed in template
| |argument
Target Milestone|--- |4.2.3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33744
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/33744] [4.1/4.2/4.3 regression] function-style cast and '>' not allowed in template argument
2007-10-12 3:10 [Bug c++/33744] New: > within function-style cast incorrectly parsed as closing template angle bracket mdorey at bluearc dot com
` (3 preceding siblings ...)
2007-10-12 15:21 ` [Bug c++/33744] [4.1/4.2/4.3 regression] function-style cast and '>' " bangerth at dealii dot org
@ 2007-10-12 17:12 ` mdorey at bluearc dot com
2007-10-15 12:54 ` jakub at gcc dot gnu dot org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: mdorey at bluearc dot com @ 2007-10-12 17:12 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from mdorey at bluearc dot com 2007-10-12 17:11 -------
Adding extra parentheses, such that "bool (2 > 1)" becomes "bool ((2 > 1 ))",
is a work-around.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33744
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/33744] [4.1/4.2/4.3 regression] function-style cast and '>' not allowed in template argument
2007-10-12 3:10 [Bug c++/33744] New: > within function-style cast incorrectly parsed as closing template angle bracket mdorey at bluearc dot com
` (4 preceding siblings ...)
2007-10-12 17:12 ` mdorey at bluearc dot com
@ 2007-10-15 12:54 ` jakub at gcc dot gnu dot org
2007-10-26 11:58 ` jakub at gcc dot gnu dot org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu dot org @ 2007-10-15 12:54 UTC (permalink / raw)
To: gcc-bugs
--
jakub at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |jakub at gcc dot gnu dot org
|dot org |
Status|NEW |ASSIGNED
Last reconfirmed|2007-10-12 15:21:49 |2007-10-15 12:53:50
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33744
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/33744] [4.1/4.2/4.3 regression] function-style cast and '>' not allowed in template argument
2007-10-12 3:10 [Bug c++/33744] New: > within function-style cast incorrectly parsed as closing template angle bracket mdorey at bluearc dot com
` (5 preceding siblings ...)
2007-10-15 12:54 ` jakub at gcc dot gnu dot org
@ 2007-10-26 11:58 ` jakub at gcc dot gnu dot org
2007-10-26 12:05 ` jakub at gcc dot gnu dot org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu dot org @ 2007-10-26 11:58 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from jakub at gcc dot gnu dot org 2007-10-26 11:58 -------
Subject: Bug 33744
Author: jakub
Date: Fri Oct 26 11:57:46 2007
New Revision: 129648
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129648
Log:
PR c++/33744
* parser.c (cp_parser_parenthesized_expression_list): Set
greater_than_is_operator_p to true in between the parens.
* g++.dg/template/arg6.C: New test.
Added:
trunk/gcc/testsuite/g++.dg/template/arg6.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/parser.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33744
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/33744] [4.1/4.2/4.3 regression] function-style cast and '>' not allowed in template argument
2007-10-12 3:10 [Bug c++/33744] New: > within function-style cast incorrectly parsed as closing template angle bracket mdorey at bluearc dot com
` (6 preceding siblings ...)
2007-10-26 11:58 ` jakub at gcc dot gnu dot org
@ 2007-10-26 12:05 ` jakub at gcc dot gnu dot org
2007-10-26 12:07 ` jakub at gcc dot gnu dot org
2007-10-26 12:08 ` jakub at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu dot org @ 2007-10-26 12:05 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from jakub at gcc dot gnu dot org 2007-10-26 12:05 -------
Subject: Bug 33744
Author: jakub
Date: Fri Oct 26 12:04:57 2007
New Revision: 129649
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129649
Log:
PR c++/33744
* parser.c (cp_parser_parenthesized_expression_list): Set
greater_than_is_operator_p to true in between the parens.
* g++.dg/template/arg6.C: New test.
Added:
branches/gcc-4_2-branch/gcc/testsuite/g++.dg/template/arg6.C
Modified:
branches/gcc-4_2-branch/gcc/cp/ChangeLog
branches/gcc-4_2-branch/gcc/cp/parser.c
branches/gcc-4_2-branch/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33744
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/33744] [4.1/4.2/4.3 regression] function-style cast and '>' not allowed in template argument
2007-10-12 3:10 [Bug c++/33744] New: > within function-style cast incorrectly parsed as closing template angle bracket mdorey at bluearc dot com
` (7 preceding siblings ...)
2007-10-26 12:05 ` jakub at gcc dot gnu dot org
@ 2007-10-26 12:07 ` jakub at gcc dot gnu dot org
2007-10-26 12:08 ` jakub at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu dot org @ 2007-10-26 12:07 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from jakub at gcc dot gnu dot org 2007-10-26 12:06 -------
Subject: Bug 33744
Author: jakub
Date: Fri Oct 26 12:06:31 2007
New Revision: 129650
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129650
Log:
PR c++/33744
* parser.c (cp_parser_parenthesized_expression_list): Set
greater_than_is_operator_p to true in between the parens.
* g++.dg/template/arg6.C: New test.
Added:
branches/gcc-4_1-branch/gcc/testsuite/g++.dg/template/arg6.C
Modified:
branches/gcc-4_1-branch/gcc/cp/ChangeLog
branches/gcc-4_1-branch/gcc/cp/parser.c
branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33744
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/33744] [4.1/4.2/4.3 regression] function-style cast and '>' not allowed in template argument
2007-10-12 3:10 [Bug c++/33744] New: > within function-style cast incorrectly parsed as closing template angle bracket mdorey at bluearc dot com
` (8 preceding siblings ...)
2007-10-26 12:07 ` jakub at gcc dot gnu dot org
@ 2007-10-26 12:08 ` jakub at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu dot org @ 2007-10-26 12:08 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from jakub at gcc dot gnu dot org 2007-10-26 12:07 -------
Fixed.
--
jakub at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33744
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2007-10-26 12:08 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-12 3:10 [Bug c++/33744] New: > within function-style cast incorrectly parsed as closing template angle bracket mdorey at bluearc dot com
2007-10-12 12:52 ` [Bug c++/33744] function-style cast not allowed in template argument bangerth at dealii dot org
2007-10-12 13:05 ` bangerth at dealii dot org
2007-10-12 13:19 ` mdorey at bluearc dot com
2007-10-12 15:21 ` [Bug c++/33744] [4.1/4.2/4.3 regression] function-style cast and '>' " bangerth at dealii dot org
2007-10-12 17:12 ` mdorey at bluearc dot com
2007-10-15 12:54 ` jakub at gcc dot gnu dot org
2007-10-26 11:58 ` jakub at gcc dot gnu dot org
2007-10-26 12:05 ` jakub at gcc dot gnu dot org
2007-10-26 12:07 ` jakub at gcc dot gnu dot org
2007-10-26 12:08 ` jakub at gcc dot gnu dot org
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).