https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103512
Bug ID: 103512
Summary: The failure of the substitution in explicit-specifier
should be considered when overload resolution
Product: gcc
Version: 11.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: xmh970252187 at gmail dot com
Target Milestone: ---
#include <iostream>
struct A{
static bool const value = true;
};
struct C{
template<class T>
explicit(T::value) C(T){}
// template<class T>
// explicit(T::value) C(T*){}
};
int main(){
A* ptr = nullptr;
C d(ptr);
}
This example is accepted by GCC, whilst it is rejected by other compilers.
According to [temp.deduct.general] p8
If a substitution results in an invalid type or expression, type deduction
fails. An invalid type or expression is one that would be ill-formed, with a
diagnostic required, if written in the same context using the substituted
arguments. Only invalid types and expressions in the immediate context of the
function type, its template parameter types, and its explicit-specifier can
result in a deduction failure.
Since there is no other candidate and the unique candidate should be considered
as deducing failure, the overload resolution should be a failure, the program
should be ill-formed.