public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/56037] New: Spurious syntax error triggered before ambiguity resolution of type-id
@ 2013-01-18 20:14 ricilake at gmail dot com
2013-01-18 20:23 ` [Bug c++/56037] " ricilake at gmail dot com
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: ricilake at gmail dot com @ 2013-01-18 20:14 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56037
Bug #: 56037
Summary: Spurious syntax error triggered before ambiguity
resolution of type-id
Classification: Unclassified
Product: gcc
Version: 4.7.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: ricilake@gmail.com
A spurious syntax error is produced by the following:
static const int zero = 0;
std::cout << (std::pair<int, int>(int(zero), int(zero))) << std::endl;
In contrast,
static const int zero = 0;
static const int zero_alias = 0;
std::cout << (std::pair<int, int>(int(zero), int(zero_alias))) << std::endl;
compiles correctly (assuming that there is an appropriate overload for
operator<<).
Section 8.2[2] states that
The ambiguity arising from the similarity between a function-style cast and a
type-id can occur in different contexts. The ambiguity appears as a choice
between a function-style cast expression and a declaration of a type. The
resolution is that any construct that could possibly be a type-id in its
syntactic context shall be considered a type-id.
In this case, 8.2[2] should not apply, since the syntactic context of the
parenthesized expression does not permit the production:
cast-expression :: ( type-id ) cast-expression
However, in the first code excerpt, where the parenthesized expression would
not be a valid type-id (because of the redefinition of the parameter name), the
syntax error is apparently being triggered before the ambiguity resolution
decides that type-id is not possible. In the second code excerpt, the
parenthesize expression could contain a valid type-id, but ambiguity resolution
rejects that possibility.
---
Bug report generated as a result of
http://stackoverflow.com/questions/14403946/adding-parenthesis-to-a-constructor-call-causes-duplicate-parameter-error-in-xlc/14404900#14404900
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/56037] Spurious syntax error triggered before ambiguity resolution of type-id
2013-01-18 20:14 [Bug c++/56037] New: Spurious syntax error triggered before ambiguity resolution of type-id ricilake at gmail dot com
@ 2013-01-18 20:23 ` ricilake at gmail dot com
2013-01-19 14:35 ` redi at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: ricilake at gmail dot com @ 2013-01-18 20:23 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56037
--- Comment #1 from ricilake at gmail dot com 2013-01-18 20:23:27 UTC ---
Created attachment 29214
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29214
Test cases as described in bug
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/56037] Spurious syntax error triggered before ambiguity resolution of type-id
2013-01-18 20:14 [Bug c++/56037] New: Spurious syntax error triggered before ambiguity resolution of type-id ricilake at gmail dot com
2013-01-18 20:23 ` [Bug c++/56037] " ricilake at gmail dot com
@ 2013-01-19 14:35 ` redi at gcc dot gnu.org
2013-07-03 9:49 ` paolo.carlini at oracle dot com
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2013-01-19 14:35 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56037
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |rejects-valid
Status|UNCONFIRMED |NEW
Last reconfirmed| |2013-01-19
Ever Confirmed|0 |1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/56037] Spurious syntax error triggered before ambiguity resolution of type-id
2013-01-18 20:14 [Bug c++/56037] New: Spurious syntax error triggered before ambiguity resolution of type-id ricilake at gmail dot com
2013-01-18 20:23 ` [Bug c++/56037] " ricilake at gmail dot com
2013-01-19 14:35 ` redi at gcc dot gnu.org
@ 2013-07-03 9:49 ` paolo.carlini at oracle dot com
2013-10-31 17:41 ` paolo.carlini at oracle dot com
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-07-03 9:49 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56037
--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Reduced:
struct T
{
T(int, int);
};
int main()
{
static const int zero = 0;
(T(int(zero), int(zero)));
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/56037] Spurious syntax error triggered before ambiguity resolution of type-id
2013-01-18 20:14 [Bug c++/56037] New: Spurious syntax error triggered before ambiguity resolution of type-id ricilake at gmail dot com
` (2 preceding siblings ...)
2013-07-03 9:49 ` paolo.carlini at oracle dot com
@ 2013-10-31 17:41 ` paolo.carlini at oracle dot com
2013-11-02 9:34 ` paolo at gcc dot gnu.org
2013-11-02 9:35 ` paolo.carlini at oracle dot com
5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-10-31 17:41 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56037
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |paolo.carlini at oracle dot com
--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> ---
This is closely related to PR29234. In fact, the patch I'm working on, as
linked from the latter, already fixes this bug too.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/56037] Spurious syntax error triggered before ambiguity resolution of type-id
2013-01-18 20:14 [Bug c++/56037] New: Spurious syntax error triggered before ambiguity resolution of type-id ricilake at gmail dot com
` (3 preceding siblings ...)
2013-10-31 17:41 ` paolo.carlini at oracle dot com
@ 2013-11-02 9:34 ` paolo at gcc dot gnu.org
2013-11-02 9:35 ` paolo.carlini at oracle dot com
5 siblings, 0 replies; 7+ messages in thread
From: paolo at gcc dot gnu.org @ 2013-11-02 9:34 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56037
--- Comment #4 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> ---
Author: paolo
Date: Sat Nov 2 09:34:13 2013
New Revision: 204312
URL: http://gcc.gnu.org/viewcvs?rev=204312&root=gcc&view=rev
Log:
/cp
2013-11-02 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/29234
PR c++/56037
* parser.c (cp_parser_cast_expression): If we aren't looking at
a cast-expression don't call cp_parser_type_id.
(cp_parser_postfix_expression): Likewise for compound-literal.
(cp_parser_tokens_start_cast_expression): Adjust.
/testsuite
2013-11-02 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/29234
PR c++/56037
* g++.dg/parse/pr29234.C: New.
* g++.dg/parse/pr56037.C: Likewise.
Added:
trunk/gcc/testsuite/g++.dg/parse/pr29234.C
trunk/gcc/testsuite/g++.dg/parse/pr56037.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/parser.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/56037] Spurious syntax error triggered before ambiguity resolution of type-id
2013-01-18 20:14 [Bug c++/56037] New: Spurious syntax error triggered before ambiguity resolution of type-id ricilake at gmail dot com
` (4 preceding siblings ...)
2013-11-02 9:34 ` paolo at gcc dot gnu.org
@ 2013-11-02 9:35 ` paolo.carlini at oracle dot com
5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-11-02 9:35 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56037
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
Target Milestone|--- |4.9.0
--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Fixed for 4.9.0.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-11-02 9:35 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-18 20:14 [Bug c++/56037] New: Spurious syntax error triggered before ambiguity resolution of type-id ricilake at gmail dot com
2013-01-18 20:23 ` [Bug c++/56037] " ricilake at gmail dot com
2013-01-19 14:35 ` redi at gcc dot gnu.org
2013-07-03 9:49 ` paolo.carlini at oracle dot com
2013-10-31 17:41 ` paolo.carlini at oracle dot com
2013-11-02 9:34 ` paolo at gcc dot gnu.org
2013-11-02 9:35 ` 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).