public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/51314] New: sizeof... and parentheses
@ 2011-11-26 16:54 marc.glisse at normalesup dot org
2011-11-26 18:27 ` [Bug c++/51314] " daniel.kruegler at googlemail dot com
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: marc.glisse at normalesup dot org @ 2011-11-26 16:54 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51314
Bug #: 51314
Summary: sizeof... and parentheses
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: marc.glisse@normalesup.org
Hello,
in some cases, g++ accepts sizeof...U (without parentheses) and in some other
cases it doesn't. I was going to report the case where it doesn't as a bug, but
after a look at the standard, it looks like it should always require the
parentheses. Well, I am not so sure, so here is one example of each:
template<int>struct A{};
template<class...U>void f(U...){
A<sizeof...U> x; // template argument 1 is invalid
}
template<int...> struct Indices;
template<class> struct Next_increasing_indices;
template<int...I> struct Next_increasing_indices<Indices<I...> > {
typedef Indices<I...,sizeof...I> type; // OK
};
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/51314] sizeof... and parentheses
2011-11-26 16:54 [Bug c++/51314] New: sizeof... and parentheses marc.glisse at normalesup dot org
@ 2011-11-26 18:27 ` daniel.kruegler at googlemail dot com
2011-12-01 22:29 ` [Bug c++/51314] [C++0x] " paolo.carlini at oracle dot com
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2011-11-26 18:27 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51314
Daniel Krügler <daniel.kruegler at googlemail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |daniel.kruegler at
| |googlemail dot com
--- Comment #1 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2011-11-26 16:02:58 UTC ---
(In reply to comment #0)
> I was going to report the case where it doesn't as a bug, but after a look at
> the standard, it looks like it should always require the parentheses.
I agree, the grammar supports only
sizeof...(/identifier/)
so both examples should be rejected.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/51314] [C++0x] sizeof... and parentheses
2011-11-26 16:54 [Bug c++/51314] New: sizeof... and parentheses marc.glisse at normalesup dot org
2011-11-26 18:27 ` [Bug c++/51314] " daniel.kruegler at googlemail dot com
@ 2011-12-01 22:29 ` paolo.carlini at oracle dot com
2012-04-19 21:20 ` marc.glisse at normalesup dot org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-12-01 22:29 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51314
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2011-12-01
Summary|sizeof... and parentheses |[C++0x] sizeof... and
| |parentheses
Ever Confirmed|0 |1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/51314] [C++0x] sizeof... and parentheses
2011-11-26 16:54 [Bug c++/51314] New: sizeof... and parentheses marc.glisse at normalesup dot org
2011-11-26 18:27 ` [Bug c++/51314] " daniel.kruegler at googlemail dot com
2011-12-01 22:29 ` [Bug c++/51314] [C++0x] " paolo.carlini at oracle dot com
@ 2012-04-19 21:20 ` marc.glisse at normalesup dot org
2012-04-30 16:37 ` jason at gcc dot gnu.org
2012-04-30 17:04 ` jason at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: marc.glisse at normalesup dot org @ 2012-04-19 21:20 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51314
--- Comment #2 from Marc Glisse <marc.glisse at normalesup dot org> 2012-04-19 21:19:23 UTC ---
Created attachment 27200
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27200
patch
s.cc: In function 'void f(U ...)':
s.cc:3:18: error: 'sizeof...' argument must be surrounded by parentheses
A<sizeof...U> x; // template argument 1 is invalid
^
s.cc:3:19: error: template argument 1 is invalid
A<sizeof...U> x; // template argument 1 is invalid
^
s.cc:3:22: error: invalid type in declaration before ';' token
A<sizeof...U> x; // template argument 1 is invalid
^
s.cc: At global scope:
s.cc:10:37: error: 'sizeof...' argument must be surrounded by parentheses
typedef Indices<I...,sizeof...I> type; // OK
^
Error recovery is not that great in the first case, but fine in the second.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/51314] [C++0x] sizeof... and parentheses
2011-11-26 16:54 [Bug c++/51314] New: sizeof... and parentheses marc.glisse at normalesup dot org
` (2 preceding siblings ...)
2012-04-19 21:20 ` marc.glisse at normalesup dot org
@ 2012-04-30 16:37 ` jason at gcc dot gnu.org
2012-04-30 17:04 ` jason at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: jason at gcc dot gnu.org @ 2012-04-30 16:37 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51314
--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> 2012-04-30 16:36:51 UTC ---
Author: jason
Date: Mon Apr 30 16:36:37 2012
New Revision: 186988
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186988
Log:
PR c++/51314
* parser.c (cp_parser_sizeof_operand): Require parentheses for
sizeof...
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/parser.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/g++.dg/cpp0x/variadic76.C
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/51314] [C++0x] sizeof... and parentheses
2011-11-26 16:54 [Bug c++/51314] New: sizeof... and parentheses marc.glisse at normalesup dot org
` (3 preceding siblings ...)
2012-04-30 16:37 ` jason at gcc dot gnu.org
@ 2012-04-30 17:04 ` jason at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: jason at gcc dot gnu.org @ 2012-04-30 17:04 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51314
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |jason at gcc dot gnu.org
Resolution| |FIXED
Target Milestone|--- |4.8.0
--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> 2012-04-30 17:02:46 UTC ---
Applied, thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-04-30 17:04 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-26 16:54 [Bug c++/51314] New: sizeof... and parentheses marc.glisse at normalesup dot org
2011-11-26 18:27 ` [Bug c++/51314] " daniel.kruegler at googlemail dot com
2011-12-01 22:29 ` [Bug c++/51314] [C++0x] " paolo.carlini at oracle dot com
2012-04-19 21:20 ` marc.glisse at normalesup dot org
2012-04-30 16:37 ` jason at gcc dot gnu.org
2012-04-30 17:04 ` jason at gcc dot gnu.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).