While trying to understand the phrase "constructors do not have names" in the C++ Standard, it seems like I found an error in clang. Could someone confirm this?
VS2015
and gcc
rejects this code, and I think they it are is correct. At least, this is the impression I get from §12.1[class.ctor]/2 in N4140:
#include <iostream>
class A {
public:
A() { std::cout << "A()" << '\n'; }
};
int main()
{
A::A();
}
§12.1[class.ctor]/2 in N4140:
A constructor is used to initialize objects of its class type. Because constructors do not have names, they are never found during name lookup; ...
With the expression A::A();
above, clang finds the constructor by name lookup, when it should find the type name A
instead. See live example.