Cause: A mismatch in template argument deduction.
Consequence: Valid C++ code would fail to compile.
Fix: Don't reduce the template level of template parameters
when performing template argument deduction substitution.
Result: The code compiles correctly.
Description of problem:
=== Console ===
~/tmp$ g++-9.1.0 -c test.cpp
test.cpp: In member function ‘void S<T>::bar()’:
test.cpp:11:20: error: no matching function for call to ‘S<T>::foo<void>(int)’
11 | foo<void>(1);
| ^
test.cpp:5:17: note: candidate: ‘template<class T> template<class U, class V> static void S<T>::foo(V)’
5 | static void foo(V)
| ^~~
test.cpp:5:17: note: template argument deduction/substitution failed:
test.cpp:11:20: note: mismatched types ‘V’ and ‘int’
11 | foo<void>(1);
|
===
Version-Release number of selected component (if applicable):
latest
How reproducible:
=== test.cpp ===
template <class T>
struct S
{
template <class U, class V>
static void foo(V)
{
}
void bar()
{
foo<void>(1);
}
};
===
Steps to Reproduce:
1.See above
2.
3.
Actual results:
See description
Expected results:
Additional info:
This is reported upstream in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90505 and https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92221
This also appears to be a regressiopn from a previous fix: https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=265734
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.
For information on the advisory, and where to find the updated
files, follow the link below.
If the solution does not work for you, open a new bug report.
https://access.redhat.com/errata/RHSA-2020:2274
Description of problem: === Console === ~/tmp$ g++-9.1.0 -c test.cpp test.cpp: In member function ‘void S<T>::bar()’: test.cpp:11:20: error: no matching function for call to ‘S<T>::foo<void>(int)’ 11 | foo<void>(1); | ^ test.cpp:5:17: note: candidate: ‘template<class T> template<class U, class V> static void S<T>::foo(V)’ 5 | static void foo(V) | ^~~ test.cpp:5:17: note: template argument deduction/substitution failed: test.cpp:11:20: note: mismatched types ‘V’ and ‘int’ 11 | foo<void>(1); | === Version-Release number of selected component (if applicable): latest How reproducible: === test.cpp === template <class T> struct S { template <class U, class V> static void foo(V) { } void bar() { foo<void>(1); } }; === Steps to Reproduce: 1.See above 2. 3. Actual results: See description Expected results: Additional info: This is reported upstream in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90505 and https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92221 This also appears to be a regressiopn from a previous fix: https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=265734