public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/53609] New: Wrong variadic template pack expansion
@ 2012-06-08 8:59 Gaetano.Checinski at googlemail dot com
2012-06-08 9:50 ` [Bug c++/53609] Wrong variadic template pack expansion in alias template redi at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Gaetano.Checinski at googlemail dot com @ 2012-06-08 8:59 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53609
Bug #: 53609
Summary: Wrong variadic template pack expansion
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: Gaetano.Checinski@googlemail.com
g++-4.7 missinterperts folowing code :
template<class...I> struct List{};
template<int I> struct Z{ static constexpr int value=I;};
template<int...I> using NumList = List< Z<I>... >;
template<class L>struct Mover;
template<template<class...>class C, class...I>
struct Mover<C<I...>>
{
using NL = NumList< I::value... > ; // aka : List< Z<I>... >
// missinterpreted as : List< Z<I...> >
};
using L=List< Z<1>,Z<2>,Z<3> >; // Works fine
using L2= NumList< 1,2,3 >; // Works also fine
Mover< L >::NL A; // dont work : should be 1 not 3 args in 'Z'
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/53609] Wrong variadic template pack expansion in alias template
2012-06-08 8:59 [Bug c++/53609] New: Wrong variadic template pack expansion Gaetano.Checinski at googlemail dot com
@ 2012-06-08 9:50 ` redi at gcc dot gnu.org
2012-08-21 6:37 ` dodji at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2012-06-08 9:50 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53609
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |rejects-valid
Status|UNCONFIRMED |NEW
Last reconfirmed| |2012-06-08
CC| |dodji at gcc dot gnu.org
Summary|Wrong variadic template |Wrong variadic template
|pack expansion |pack expansion in alias
| |template
Ever Confirmed|0 |1
Known to fail| |4.7.0, 4.8.0
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-06-08 09:49:33 UTC ---
Confirmed.
It works fine if you rewrite it without alias templates:
template<int...I> struct NumList { typedef List< Z<I...> > type; };
then use NumList::type instead of NumList, so the problem is with the alias
template substitution.
G++ seems to be treating Z<I>... as Z<I...> in the type-id of the
alias-declaration.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/53609] Wrong variadic template pack expansion in alias template
2012-06-08 8:59 [Bug c++/53609] New: Wrong variadic template pack expansion Gaetano.Checinski at googlemail dot com
2012-06-08 9:50 ` [Bug c++/53609] Wrong variadic template pack expansion in alias template redi at gcc dot gnu.org
@ 2012-08-21 6:37 ` dodji at gcc dot gnu.org
2012-09-20 8:48 ` dodji at seketeli dot org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: dodji at gcc dot gnu.org @ 2012-08-21 6:37 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53609
Dodji Seketeli <dodji at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
AssignedTo|unassigned at gcc dot |dodji at gcc dot gnu.org
|gnu.org |
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/53609] Wrong variadic template pack expansion in alias template
2012-06-08 8:59 [Bug c++/53609] New: Wrong variadic template pack expansion Gaetano.Checinski at googlemail dot com
2012-06-08 9:50 ` [Bug c++/53609] Wrong variadic template pack expansion in alias template redi at gcc dot gnu.org
2012-08-21 6:37 ` dodji at gcc dot gnu.org
@ 2012-09-20 8:48 ` dodji at seketeli dot org
2013-01-22 10:05 ` dodji at gcc dot gnu.org
2013-01-30 11:45 ` dodji at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: dodji at seketeli dot org @ 2012-09-20 8:48 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53609
--- Comment #2 from dodji at seketeli dot org <dodji at seketeli dot org> 2012-09-20 08:48:09 UTC ---
A candidate patch for this has been sent to
http://gcc.gnu.org/ml/gcc-patches/2012-09/msg01436.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/53609] Wrong variadic template pack expansion in alias template
2012-06-08 8:59 [Bug c++/53609] New: Wrong variadic template pack expansion Gaetano.Checinski at googlemail dot com
` (2 preceding siblings ...)
2012-09-20 8:48 ` dodji at seketeli dot org
@ 2013-01-22 10:05 ` dodji at gcc dot gnu.org
2013-01-30 11:45 ` dodji at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: dodji at gcc dot gnu.org @ 2013-01-22 10:05 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53609
--- Comment #3 from Dodji Seketeli <dodji at gcc dot gnu.org> 2013-01-22 10:05:13 UTC ---
Author: dodji
Date: Tue Jan 22 10:05:05 2013
New Revision: 195367
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195367
Log:
PR c++/53609 - Wrong variadic template pack expansion in alias template
Consider this example:
1 template<class...I> struct List {};
2 template<int T> struct Z {static const int value = T;};
3 template<int...T> using LZ = List<Z<T>...>;
4
5 template<class...U>
6 struct F
7 {
8 using N = LZ<U::value...>; //#1 This should amount to
List<Z<U::value>...>
9 }
10
11 F<Z<1>, Z<2> >::N A; //#2
which G++ fails to compile, with this error message:
test-PR53609-3.cc: In instantiation of 'struct F<Z<1>, Z<2> >':
test-PR53609-3.cc:11:15: required from here
test-PR53609-3.cc:3:43: error: wrong number of template arguments (2, should be
1)
template<int...T> using LZ = List<Z<T>...>;
^
test-PR53609-3.cc:2:24: error: provided for 'template<int T> struct Z'
template<int T> struct Z {static const int value = T;};
I think this is because in #1, when we substitute the argument pack
{U::value...} into the pack expansion Z<T>..., tsubst_pack_expansion
yields Z<U::value...>, instead of Z<U::value>..., so the instantiation
of LZ amounts to List<Z<U::value...> >, instead of
List<Z<U::value>...>.
The idea of this patch is to make tsubst_pack_expansion support
substituting an argument pack (into a pack expansion) where one of the
arguments (let's call it the Ith argument) is itself a pack expansion
P. In that case, the Ith element resulting from the substituting
should be a pack expansion P'.
The pattern of P' is then the pattern of P into which the pattern of
the Ith argument of the argument pack has been substituted.
Tested on x86_64-unknown-linux-gnu against trunk.
gcc/cp/
* pt.c (argument_pack_element_is_expansion_p)
(make_argument_pack_select, use_pack_expansion_extra_args_p)
(gen_elem_of_pack_expansion_instantiation): New static functions.
(tsubst): When looking through an ARGUMENT_PACK_SELECT tree node,
look through the possibly resulting pack expansion as well.
(tsubst_pack_expansion): Use use_pack_expansion_extra_p to
generalize when to use the PACK_EXPANSION_EXTRA_ARGS mechanism.
Use gen_elem_of_pack_expansion_instantiation to build the
instantiation piece-wise. Don't use arg_from_parm_pack_p anymore,
as gen_elem_of_pack_expansion_instantiation and the change in
tsubst above generalize this particular case.
(arg_from_parm_pack_p): Remove this for it's not used by
tsubst_pack_expansion anymore.
gcc/testsuite/
* g++.dg/cpp0x/variadic139.C: New test.
* g++.dg/cpp0x/variadic140.C: Likewise.
* g++.dg/cpp0x/variadic141.C: Likewise.
Added:
trunk/gcc/testsuite/g++.dg/cpp0x/variadic139.C
trunk/gcc/testsuite/g++.dg/cpp0x/variadic140.C
trunk/gcc/testsuite/g++.dg/cpp0x/variadic141.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/pt.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/53609] Wrong variadic template pack expansion in alias template
2012-06-08 8:59 [Bug c++/53609] New: Wrong variadic template pack expansion Gaetano.Checinski at googlemail dot com
` (3 preceding siblings ...)
2013-01-22 10:05 ` dodji at gcc dot gnu.org
@ 2013-01-30 11:45 ` dodji at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: dodji at gcc dot gnu.org @ 2013-01-30 11:45 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53609
Dodji Seketeli <dodji at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
--- Comment #4 from Dodji Seketeli <dodji at gcc dot gnu.org> 2013-01-30 11:44:49 UTC ---
Fixed in trunk (4.8)
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-01-30 11:45 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-08 8:59 [Bug c++/53609] New: Wrong variadic template pack expansion Gaetano.Checinski at googlemail dot com
2012-06-08 9:50 ` [Bug c++/53609] Wrong variadic template pack expansion in alias template redi at gcc dot gnu.org
2012-08-21 6:37 ` dodji at gcc dot gnu.org
2012-09-20 8:48 ` dodji at seketeli dot org
2013-01-22 10:05 ` dodji at gcc dot gnu.org
2013-01-30 11:45 ` dodji 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).