public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/40155]  New: [c++1x] variadic template pack problem
@ 2009-05-15  2:55 bangerth at gmail dot com
  2009-05-15  2:56 ` [Bug c++/40155] " bangerth at gmail dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: bangerth at gmail dot com @ 2009-05-15  2:55 UTC (permalink / raw)
  To: gcc-bugs

I'm fairly sure this should compile but it doesn't:
---------------------
template <typename T> struct identity
{  typedef T type;  };

template <typename RT, typename... A>
int forward_call(RT (*) (A...), typename identity<A>::type...);

int g (double);

int i = forward_call(&g, 0);
-------------------------------------

The problem is the expansion
  typename identity<A>::type...
which should wrap identity<An>::type around each element An of the
template pack A. I'm not entirely familiar with all the rules for
template packs yet, but I think that this should work, taking
the examples in
  http://www.jot.fm/issues/issue_2008_02/article2/
into account.

Best
 W.


-- 
           Summary: [c++1x] variadic template pack problem
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bangerth at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40155


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/40155] [c++1x] variadic template pack problem
  2009-05-15  2:55 [Bug c++/40155] New: [c++1x] variadic template pack problem bangerth at gmail dot com
@ 2009-05-15  2:56 ` bangerth at gmail dot com
  2010-01-04 23:13 ` [Bug c++/40155] [c++0x] " dodji at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: bangerth at gmail dot com @ 2009-05-15  2:56 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from bangerth at gmail dot com  2009-05-15 02:56 -------
Oh, should've said:

g/x> /home/bangerth/bin/x86/gcc-mainline/bin/c++ -std=c++0x -c x.cc
x.cc:9: error: invalid conversion from 'int (*)(double)' to 'int (*)()'
x.cc:5: error: too many arguments to function 'int forward_call(RT (*)(A ...),
typename identity<A>::type ...) [with RT = int, A = , typename
identity<A>::type = A]'
x.cc:9: error: at this point in file


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40155


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/40155] [c++0x] variadic template pack problem
  2009-05-15  2:55 [Bug c++/40155] New: [c++1x] variadic template pack problem bangerth at gmail dot com
  2009-05-15  2:56 ` [Bug c++/40155] " bangerth at gmail dot com
@ 2010-01-04 23:13 ` dodji at gcc dot gnu dot org
  2010-01-05 11:44 ` dodji at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: dodji at gcc dot gnu dot org @ 2010-01-04 23:13 UTC (permalink / raw)
  To: gcc-bugs



-- 

dodji at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |dodji at gcc dot gnu dot org
                   |dot org                     |
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2010-01-04 23:12:53
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40155


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/40155] [c++0x] variadic template pack problem
  2009-05-15  2:55 [Bug c++/40155] New: [c++1x] variadic template pack problem bangerth at gmail dot com
  2009-05-15  2:56 ` [Bug c++/40155] " bangerth at gmail dot com
  2010-01-04 23:13 ` [Bug c++/40155] [c++0x] " dodji at gcc dot gnu dot org
@ 2010-01-05 11:44 ` dodji at gcc dot gnu dot org
  2010-01-05 13:20 ` bangerth at gmail dot com
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: dodji at gcc dot gnu dot org @ 2010-01-05 11:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from dodji at gcc dot gnu dot org  2010-01-05 11:43 -------
FWIW, I think this code is valid.

The A template parameter in "typename identity<A>::type..." is in a non-deduced
context, so it's argument should not be deduced from there. The argument of A
should be re-used from the deduction done using "RT (*) (A...)".

And I think that's where the problem is. Once the compiler figured the second
argument of forward_call is a non-deduced context, it fails to re-use the
argument of A that was deduced in the context of the first argument of
forward_call.

I believe this should be flagged P1, even if it doesn't seem to be a
regression.


-- 

dodji at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40155


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/40155] [c++0x] variadic template pack problem
  2009-05-15  2:55 [Bug c++/40155] New: [c++1x] variadic template pack problem bangerth at gmail dot com
                   ` (2 preceding siblings ...)
  2010-01-05 11:44 ` dodji at gcc dot gnu dot org
@ 2010-01-05 13:20 ` bangerth at gmail dot com
  2010-01-05 13:32 ` dodji at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: bangerth at gmail dot com @ 2010-01-05 13:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from bangerth at gmail dot com  2010-01-05 13:20 -------
(In reply to comment #2)
> I believe this should be flagged P1, even if it doesn't seem to be a
> regression.

I'm obviously not impartial, but this is the sort of code that template
packs are supposed to support, and forwarding calls is one of its main
objectives. So I would definitely support getting this to work in 4.5...

W.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40155


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/40155] [c++0x] variadic template pack problem
  2009-05-15  2:55 [Bug c++/40155] New: [c++1x] variadic template pack problem bangerth at gmail dot com
                   ` (3 preceding siblings ...)
  2010-01-05 13:20 ` bangerth at gmail dot com
@ 2010-01-05 13:32 ` dodji at gcc dot gnu dot org
  2010-01-07 19:22 ` dodji at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: dodji at gcc dot gnu dot org @ 2010-01-05 13:32 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from dodji at gcc dot gnu dot org  2010-01-05 13:31 -------
Patch submitted to http://gcc.gnu.org/ml/gcc-patches/2010-01/msg00205.html


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40155


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/40155] [c++0x] variadic template pack problem
  2009-05-15  2:55 [Bug c++/40155] New: [c++1x] variadic template pack problem bangerth at gmail dot com
                   ` (4 preceding siblings ...)
  2010-01-05 13:32 ` dodji at gcc dot gnu dot org
@ 2010-01-07 19:22 ` dodji at gcc dot gnu dot org
  2010-01-07 19:47 ` dodji at gcc dot gnu dot org
  2010-02-07  4:02 ` hjl dot tools at gmail dot com
  7 siblings, 0 replies; 9+ messages in thread
From: dodji at gcc dot gnu dot org @ 2010-01-07 19:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from dodji at gcc dot gnu dot org  2010-01-07 19:22 -------
Subject: Bug 40155

Author: dodji
Date: Thu Jan  7 19:21:46 2010
New Revision: 155705

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=155705
Log:
Fix PR c++/40155

gcc/cp/ChangeLog:
        c++/40155
        * pt.c (unify_pack_expansion): In non-deduced contexts, re-use template
        arguments that were previously deduced.

gcc/testsuite/ChangeLog:
        c++/40155
        * g++.dg/cpp0x/variadic-unify-2.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/variadic-unify-2.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40155


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/40155] [c++0x] variadic template pack problem
  2009-05-15  2:55 [Bug c++/40155] New: [c++1x] variadic template pack problem bangerth at gmail dot com
                   ` (5 preceding siblings ...)
  2010-01-07 19:22 ` dodji at gcc dot gnu dot org
@ 2010-01-07 19:47 ` dodji at gcc dot gnu dot org
  2010-02-07  4:02 ` hjl dot tools at gmail dot com
  7 siblings, 0 replies; 9+ messages in thread
From: dodji at gcc dot gnu dot org @ 2010-01-07 19:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from dodji at gcc dot gnu dot org  2010-01-07 19:47 -------
Fixed in 4.5


-- 

dodji at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40155


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/40155] [c++0x] variadic template pack problem
  2009-05-15  2:55 [Bug c++/40155] New: [c++1x] variadic template pack problem bangerth at gmail dot com
                   ` (6 preceding siblings ...)
  2010-01-07 19:47 ` dodji at gcc dot gnu dot org
@ 2010-02-07  4:02 ` hjl dot tools at gmail dot com
  7 siblings, 0 replies; 9+ messages in thread
From: hjl dot tools at gmail dot com @ 2010-02-07  4:02 UTC (permalink / raw)
  To: gcc-bugs



-- 

hjl dot tools at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.5.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40155


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2010-02-07  4:02 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-15  2:55 [Bug c++/40155] New: [c++1x] variadic template pack problem bangerth at gmail dot com
2009-05-15  2:56 ` [Bug c++/40155] " bangerth at gmail dot com
2010-01-04 23:13 ` [Bug c++/40155] [c++0x] " dodji at gcc dot gnu dot org
2010-01-05 11:44 ` dodji at gcc dot gnu dot org
2010-01-05 13:20 ` bangerth at gmail dot com
2010-01-05 13:32 ` dodji at gcc dot gnu dot org
2010-01-07 19:22 ` dodji at gcc dot gnu dot org
2010-01-07 19:47 ` dodji at gcc dot gnu dot org
2010-02-07  4:02 ` hjl dot tools at gmail 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).