Consider the following code snippet:
template <typename T>
struct foo
{
foo(T) { }
};
int main()
{
foo{0};
}
g++ 7 happily creates a temporary object of type foo
, deducing T = int
.
clang++ 5 and 6 refuse to compile the code:
error: expected unqualified-id foo{0}; ^
Is this a clang bug, or is there something in the Standard that prevents class template argument deduction from kicking in for unnamed temporaries?
Clang bug (#34091)
From [dcl.type.class.deduct]: