4

我们中的一些人知道 C++ 对象有几个可能的构造函数,C1 和 C2。但是 GCC 消息来源说可以有构造函数的第三种变体,C3“完整的对象分配构造函数”(在函数gcc-4.8/gcc/cp/mangle.c之前检查文件write_special_name_constructor):

http://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/cp/mangle.c;h=10c2e2beb0c422e4f56e17e7659fbeb4ab3ee31b;hb=refs/tags/gcc-4_8_1-release#l1644

1645 /* Handle constructor productions of non-terminal <special-name>.
1646    CTOR is a constructor FUNCTION_DECL.
1647 
1648      <special-name> ::= C1   # complete object constructor
1649                     ::= C2   # base object constructor
1650                     ::= C3   # complete object allocating constructor
1651 
1652    Currently, allocating constructors are never used.    <<<<<
1653 
1654    We also need to provide mangled names for the maybe-in-charge
1655    constructor, so we treat it here too.  mangle_decl_string will
1656    append *INTERNAL* to that, to make sure we never emit it.  */

为什么可能需要 C3,但 GCC 不使用?是否有任何流行的 C++ 编译器可以生成 C3 构造函数?

C3 是否记录在任何 ABI pdf 中?

4

1 回答 1

4

这个想法是C3的优化版本::operator new(sizeof(class))C1即预内联版本。GCC 必须创建它以防其他编译器使用它。这显然可能取决于内联决策,这些决策通常很重要。

于 2013-07-18T23:34:20.897 回答