Bug 56190 - GCC fails deducing a "void(*)(int, float, double)" to a "void(*)(T..., float, double)" with T={int}
Summary: GCC fails deducing a "void(*)(int, float, double)" to a "void(*)(T..., float,...
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.3
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
: 69205 84893 104672 105796 (view as bug list)
Depends on:
Blocks: 66670
  Show dependency treegraph
 
Reported: 2013-02-03 13:57 UTC by Johannes Schaub
Modified: 2023-09-22 18:23 UTC (History)
7 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-07-27 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Johannes Schaub 2013-02-03 13:57:13 UTC
From http://stackoverflow.com/questions/14664589/variadic-template-code-compiles-on-gcc-4-6-but-not-on-clang-or-gcc-4-7 :

class Test {
    public:
    template <class... A2> void print (void(*function)(A2..., float, double)) {

    }
};

void test_print (int a, float b, double c) { }

int main () {
    Test test;
    test.print<int> (&test_print);
}

Fails with

source.cpp:14:33: note: candidate is:
source.cpp:3:33: note: template<class ... A2> void Test::print(void (*)(A2 ..., float, double))
source.cpp:3:33: note:   template argument deduction/substitution failed:
source.cpp:14:33: note:   mismatched types 'float' and 'int'

GCC does apparently not substitute the explicitly specified arguments of "A2" before attempting the argument deduction.
Comment 1 Andrew Pinski 2021-07-27 07:06:09 UTC
Confirmed.
Comment 2 Andrew Pinski 2021-07-27 07:06:26 UTC
*** Bug 84893 has been marked as a duplicate of this bug. ***
Comment 3 Andrew Pinski 2021-08-10 03:02:40 UTC
*** Bug 69205 has been marked as a duplicate of this bug. ***
Comment 4 Andrew Pinski 2022-02-24 10:26:32 UTC
*** Bug 104672 has been marked as a duplicate of this bug. ***
Comment 5 Andrew Pinski 2022-05-31 23:30:19 UTC
*** Bug 105796 has been marked as a duplicate of this bug. ***
Comment 6 Andrew Pinski 2022-05-31 23:32:05 UTC
Simplier example:
```
int func(int, char);

template<typename... TArgs>
int testFunc(int (*)(TArgs..., char));

int x = testFunc<int>(func);
```