为什么C3分配构造函数从未使用? [英] Why are C3 allocating constructors never used?

查看:176
本文介绍了为什么C3分配构造函数从未使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们中的一些人知道,对于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 / *处理非终端< special-name>的构造函数制作。 
1646 CTOR是一个构造函数FUNCTION_DECL。
1647
1648< special-name> :: = C1#完整对象构造函数
1649 :: = C2#基础对象构造函数
1650 :: = C3#完成对象分配构造函数
1651
1652目前,分配构造函数是没用过。 <<<<<
1653
1654我们还需要为可能负责的
1655构造函数提供错误的名称,所以我们也要在这里处理它。 mangle_decl_string将
1656追加* INTERNAL *,以确保我们永远不会发出它。 * /

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



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

C3 是一个优化版本 :: operator new(sizeof (class))后跟 C1 ,即预先内联的版本。 GCC必须创建它以防其他编译器使用它。这显然可能取决于内联决策,这通常是非平凡的。

Some of us know that there are several constructors possible for C++ object, C1 and C2. But GCC sources says that there is can be third variant of constructor, the C3 "complete object allocating constructor" (check gcc-4.8/gcc/cp/mangle.c file just before write_special_name_constructor function):

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.  */

Why the C3 may be needed, but not used by GCC? Is there any popular C++ compiler, which generates C3 constructors?

Is the C3 documented in any ABI pdf?

解决方案

The idea is that C3 is an optimized version of ::operator new(sizeof(class)) followed by C1, i.e. a pre-inlined version. GCC has to create it in case another compiler uses it. That may obviously depend on inlining decisions, which are generally non-trivial.

这篇关于为什么C3分配构造函数从未使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆