为什么C3分配构造函数从未使用过
Why are C3 allocating constructors never used?
我们中的一些人知道C++对象可能有几个构造函数,C1和C2。但GCC消息人士表示,构造函数可能有第三种变体,C3"完全对象分配构造函数"(在write_special_name_constructor
函数之前检查gcc-4.8/gcc/cp/mangle.c
文件):
http://gcc.gnu.org/git/?p=gcc.git;a=斑点;f=gcc/cp/mangle.c;h=10c2e2beb0c422e4f56e17e7659fbeb4a3ee31b;hb=refs/tags/gcc-4_8_1-租约#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. */
为什么GCC可能需要C3,但不使用?有没有流行的C++编译器可以生成C3构造函数?
C3是否记录在任何ABI pdf中?
其思想是C3
是::operator new(sizeof(class))
的优化版本,然后是C1
,即预内联版本。GCC必须创建它,以防另一个编译器使用它。这显然取决于内联决策,而内联决策通常是不重要的。
相关文章:
- 使用构造函数初始化结构还是在之后设置其值更好?
- 使用构造函数从函数返回对象
- 如何使用构造函数声明指向用户定义对象的指针?
- 这是使用构造函数初始化数组对象的最佳方法吗?
- 在C++中初始化带有和不使用构造函数调用的对象有什么区别
- 如何使用构造函数中的参数来调用C++中另一个类的构造函数?
- 我应该在C++中使用构造函数还是初始化函数
- 我们可以直接为任何数据成员赋值. 为什么要使用构造函数?
- 创建/向容器添加对象时如何使用构造函数/析构函数
- 如何使用构造函数初始化内存地址(指针变量)?
- 创建一个类并在C++中使用构造函数(赋值)
- 当您可以使用构造函数时,为什么要重载 C++ 类或结构中的 () 运算符(可调用运算符)
- 使用构造函数作为成员函数的 C++(用于序列化)
- 拥有这个未使用的函数 Init 有什么意义
- 使用构造函数的可变参数中的其他模板化类执行模板化类的初始化
- 尝试使用构造函数创建对象时出错
- 为什么 C++ 的创建者决定使用构造函数初始值设定项列表来初始化基类?
- 当父类在 C++ 中没有默认构造函数时,如何在继承的类中使用构造函数?
- 无法使用构造函数为类函数赋值
- 当基类未指定构造函数时,如何使用仅具有带参数的构造函数的类派生基类?