短语“构造函数”的含义没有名称“在C ++标准 [英] Meaning of phrase "constructors do not have names" in the C++ Standard
问题描述
在C ++标准中尝试理解短语构造函数没有名称时,似乎我在clang中发现了一个错误。
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
code> gcc 拒绝此代码,我认为 是正确的。至少,这是我从N4140中的§12.1[class.ctor] / 2的印象:
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 在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; ...
使用表达式 A :: A();
,clang通过名称查找找到构造函数,当它应该找到类型名称 A
。请参见实例。
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.
推荐答案
您的直觉是正确的。这是一个已知的ang错 13403 ,状态为 NEW
。
Your intuition is correct. This is a known Clang bug 13403 with status NEW
.
这篇关于短语“构造函数”的含义没有名称“在C ++标准的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!