Discussion:
[Bug c++/46394] New: [C++0X] no matching function with default template argument
marc.glisse at normalesup dot org
15 years ago
Permalink
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46394

Summary: [C++0X] no matching function with default template
argument
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: ***@gcc.gnu.org
ReportedBy: ***@normalesup.org


This code recently stopped compiling. (I have a remove_cv on top of the
remove_reference in the original code but it didn't look necessary to reproduce
the problem)

#include <utility>
#include <tuple>
#include <type_traits>
struct A {
template<class...U,class=
typename std::enable_if<
!std::is_same<
std::tuple<typename std::remove_reference<U>::type...>,
std::tuple<A>
::value
::type
A(U&&...u) ;
};
int main(){
A a(1,2,3);
}


bug.cc: In function ‘int main()’:
bug.cc:16:11: error: no matching function for call to ‘A::A(int, int, int)’
bug.cc:13:13: note: candidates are: template<class ... U, class> A::A(U&& ...)
bug.cc:4:8: note: constexpr A::A(const A&)
bug.cc:4:8: note: constexpr A::A(A&&)
paolo.carlini at oracle dot com
15 years ago
Permalink
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46394

Paolo Carlini <paolo.carlini at oracle dot com> changed:

What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2010.11.09 14:58:23
CC| |jason at gcc dot gnu.org
Summary|[C++0X] no matching |[C++0X] [4.6 Regression] no
|function with default |matching function with
|template parameter |default template parameter
Ever Confirmed|0 |1

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2010-11-09 14:58:23 UTC ---
Let's add Jason. I'm pretty sure this isn't a library issue because the same
happens with just:

template<class...U>
struct tuple;

and outside std::tuple the rest is pretty trivial as far as the library is
concerned.
paolo.carlini at oracle dot com
15 years ago
Permalink
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46394

Paolo Carlini <paolo.carlini at oracle dot com> changed:

What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |4.6.0
marc.glisse at normalesup dot org
14 years ago
Permalink
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46394

--- Comment #2 from Marc Glisse <marc.glisse at normalesup dot org> 2010-12-17 20:04:18 UTC ---
Note that if I change the function to:

template<class...U,class=
typename std::enable_if<
!std::is_same<
std::tuple<U&&...>,
void
::value
::type
A(U&&...u) ;

I get:

sorry, unimplemented: use of 'type_pack_expansion' in template
hjl.tools at gmail dot com
14 years ago
Permalink
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46394

H.J. Lu <hjl.tools at gmail dot com> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |dseketel at redhat dot com

--- Comment #3 from H.J. Lu <hjl.tools at gmail dot com> 2010-12-17 20:10:12 UTC ---
It is caused by revision 166179:

http://gcc.gnu.org/ml/gcc-cvs/2010-11/msg00065.html
dodji at gcc dot gnu.org
14 years ago
Permalink
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46394

Dodji Seketeli <dodji at gcc dot gnu.org> changed:

What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
CC|dseketel at redhat dot com |dodji at gcc dot gnu.org
AssignedTo|unassigned at gcc dot |dodji at gcc dot gnu.org
|gnu.org |
dodji at gcc dot gnu.org
14 years ago
Permalink
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46394

--- Comment #4 from Dodji Seketeli <dodji at gcc dot gnu.org> 2011-01-04 15:32:53 UTC ---
I think what's happening is, at some point during template parameters
fixup (to build proper canonical types for dependent parms) we try to
substitute the U template parameter pack [and the the remaining unamed
template parm] into the pattern of the default argument
std::remote_reference<U>::type... . The TYPENAME_TYPE case of tsubst then
logically calls tsubst_aggr_type on 'std::remote_reference<U>'. That
later function in turn calls lookup_template_class with
std::remote_reference as argument to D1 and a TYPE_PACK_EXPANSION
built for the template parameter U (by template_parm_to_arg) and
argument to ARGLIST.

At that point we are trying to match a template argument which is
a pack expansion with a template parameter that is not a
parameter pack - and we hit
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35722.

So I think I am going to focus on that bug and see.
dodji at gcc dot gnu.org
14 years ago
Permalink
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46394

Dodji Seketeli <dodji at gcc dot gnu.org> changed:

What |Removed |Added
----------------------------------------------------------------------------
Depends on|35722 |

--- Comment #5 from Dodji Seketeli <dodji at gcc dot gnu.org> 2011-02-04 19:53:24 UTC ---
Actually my previous analysis wasn't quite right. Rather, the
substitution of the fixed up U into std::remove_reference<U>::type...,
fails. It fails because we fail to compare the fixed up U with the
non-fixed up U. And after that the sky falls.

So this has nothing to do with
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35722, luckily. Pheew.

A candidate patch was sent to to
http://gcc.gnu.org/ml/gcc-patches/2011-02/msg00295.html along with a
smaller reproducer.
rguenth at gcc dot gnu.org
14 years ago
Permalink
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46394

Richard Guenther <rguenth at gcc dot gnu.org> changed:

What |Removed |Added
----------------------------------------------------------------------------
Keywords| |rejects-valid
Priority|P3 |P1
dodji at gcc dot gnu.org
14 years ago
Permalink
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46394

--- Comment #6 from Dodji Seketeli <dodji at gcc dot gnu.org> 2011-02-20 17:37:06 UTC ---
Author: dodji
Date: Sun Feb 20 17:37:03 2011
New Revision: 170341

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=170341
Log:
PR c++/46394

gcc/cp/

PR c++/46394
* pt.c (tsubst_pack_expansion): do not use
cp_tree_equal/same_type_p to detect an expansion of a parameter
pack.

gcc/testsuite/

PR c++/46394
* g++.dg/template/typedef38.C: New test.

Added:
trunk/gcc/testsuite/g++.dg/template/typedef38.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/pt.c
trunk/gcc/testsuite/ChangeLog
dodji at gcc dot gnu.org
14 years ago
Permalink
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46394

--- Comment #7 from Dodji Seketeli <dodji at gcc dot gnu.org> 2011-02-20 18:08:14 UTC ---
Fixed in trunk (4.6).
dodji at gcc dot gnu.org
14 years ago
Permalink
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46394

Dodji Seketeli <dodji at gcc dot gnu.org> changed:

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

--- Comment #8 from Dodji Seketeli <dodji at gcc dot gnu.org> 2011-02-20 18:09:04 UTC ---
Really close the bug.

Continue reading on narkive:
Loading...