public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/66670] New: "template argument deduction/substitution failed" with function pointers and multiple parameter packs
@ 2015-06-25 15:06 michael at ensslin dot cc
  2021-07-27  7:11 ` [Bug c++/66670] " pinskia at gcc dot gnu.org
  2021-08-23  9:03 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: michael at ensslin dot cc @ 2015-06-25 15:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66670

            Bug ID: 66670
           Summary: "template argument deduction/substitution failed" with
                    function pointers and multiple parameter packs
           Product: gcc
           Version: 5.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: michael at ensslin dot cc
  Target Milestone: ---

Take this example:

$ cat t28.cpp
template<class ... Ts>
struct S {
        template<class ... Us>
        void foo(void (*)(Us..., Ts ...)) {}
};

void f(float, int) {}

int main() {
        S<int>().foo<float>(f);
}

$ g++-4.9 -std=c++14 t28.cpp
t28.cpp: In function ‘int main()’:
t28.cpp:10:23: error: no matching function for call to ‘S<int>::foo(void
(&)(float, int))’
  S<int>().foo<float>(f);
                       ^
t28.cpp:10:23: note: candidate is:
t28.cpp:4:7: note: template<class ... Us> void S<Ts>::foo(void (*)(Us ..., Ts
...)) [with Us = {Us ...}; Ts = {int}]
  void foo(void (*)(Us..., Ts ...)) {}
       ^
t28.cpp:4:7: note:   template argument deduction/substitution failed:
t28.cpp:10:23: note:   mismatched types ‘int’ and ‘float’
  S<int>().foo<float>(f);
                       ^
$ g++-4.9 --version
g++-4.9 (Debian 4.9.2-22) 4.9.2

I have reproduced the issue with g++-5.1.0 using https://gcc.godbolt.org/.

Note that clang++ has this issue as well, but it works with icc and supposedly
even MSVC.

The issue can be fixed by swapping the order of Us... and Ts... in the function
pointer type, or by replacing the function pointer type by some other type like
std::tuple.

Related: http://stackoverflow.com/questions/31040075

clang++ error, for completeness:

$ clang++-3.7 -std=c++14 t28.cpp
t28.cpp:10:11: error: no matching member function for call to 'foo'
        S<int>().foo<float>(f);
        ~~~~~~~~~^~~~~~~~~~
t28.cpp:4:7: note: candidate template ignored: failed template argument
deduction
        void foo(void (*)(Us..., Ts ...)) {}
             ^
1 error generated.

$ clang++-3.7 --version
Debian clang version 3.7.0-svn239806-1+b1 (trunk) (based on LLVM 3.7.0)
Target: x86_64-pc-linux-gnu
Thread model: posix
>From gcc-bugs-return-490210-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Jun 25 15:48:47 2015
Return-Path: <gcc-bugs-return-490210-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 40667 invoked by alias); 25 Jun 2015 15:48:46 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 40524 invoked by uid 48); 25 Jun 2015 15:48:43 -0000
From: "glaubitz at physik dot fu-berlin.de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/65979] [5/6 Regression] [SH] Wrong code is generated with stage1 compiler
Date: Thu, 25 Jun 2015 15:48:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: target
X-Bugzilla-Version: 5.1.1
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: glaubitz at physik dot fu-berlin.de
X-Bugzilla-Status: NEW
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-65979-4-IHClRf49rq@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-65979-4@http.gcc.gnu.org/bugzilla/>
References: <bug-65979-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-06/txt/msg02542.txt.bz2
Content-length: 337

https://gcc.gnu.org/bugzilla/show_bug.cgi?ide979

--- Comment #42 from John Paul Adrian Glaubitz <glaubitz at physik dot fu-berlin.de> ---
(In reply to Kazumoto Kojima from comment #41)
> Maybe.  Trying it with Oleg's patch is a good idea.

Is it applied yet? Otherwise I really will have to look into building gcc-5
from SVN myself.


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

* [Bug c++/66670] "template argument deduction/substitution failed" with function pointers and multiple parameter packs
  2015-06-25 15:06 [Bug c++/66670] New: "template argument deduction/substitution failed" with function pointers and multiple parameter packs michael at ensslin dot cc
@ 2021-07-27  7:11 ` pinskia at gcc dot gnu.org
  2021-08-23  9:03 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-27  7:11 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66670

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Depends on|                            |56190

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I suspect PR 56190 is very much the same bug.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56190
[Bug 56190] GCC fails deducing a "void(*)(int, float, double)" to a
"void(*)(T..., float, double)" with T={int}

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

* [Bug c++/66670] "template argument deduction/substitution failed" with function pointers and multiple parameter packs
  2015-06-25 15:06 [Bug c++/66670] New: "template argument deduction/substitution failed" with function pointers and multiple parameter packs michael at ensslin dot cc
  2021-07-27  7:11 ` [Bug c++/66670] " pinskia at gcc dot gnu.org
@ 2021-08-23  9:03 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-23  9:03 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66670

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=83542

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Also related to PR 83542.

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

end of thread, other threads:[~2021-08-23  9:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-25 15:06 [Bug c++/66670] New: "template argument deduction/substitution failed" with function pointers and multiple parameter packs michael at ensslin dot cc
2021-07-27  7:11 ` [Bug c++/66670] " pinskia at gcc dot gnu.org
2021-08-23  9:03 ` pinskia 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).