There is some very basic example of C++ function template overloading resolution below (minimized from actual code)
struct S {
S() {}
S(int) {}
};
template <typename T = S>
void foo(T x) { std::cout << "S" << std::endl; }
template <>
void foo<S>(S x) { std::cout << "S spc" << std::endl; }
int main() {
foo({});
foo(0);
}
Here we have two cases. In first case compiler shall default-initialize something (like S) in second case convert int to something (like S)
I believe in both cases specialization shall win overloading because specialization perfectly matches and is really more specialized then primary template by partial ordering [temp.deduct.partial]
But both clang 11 and gcc 10.2 in this example agrees that in second case primary template wins. Is this bug in both compilers or (probably) I don't understand something about C++ standard?
` and having to construct a temporary `S` object from `0`.