2013-07-18 27 views
1

我們中的一些人知道C++對象C1和C2可能有several constructors。但是GCC來源說,有可能構造的第三變形,C3「完整的對象分配構造」(檢查gcc-4.8/gcc/cp/mangle.c文件之前write_special_name_constructor功能):爲什麼從未使用C3分配構造函數?

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?

+1

它在Itanium C++ ABI中提到:http://www.swag.uwaterloo.ca/acd/docs/ItaniumC++ABI.htm何時以及爲什麼(或爲什麼不)使用它 - 不知道: -/ –

+1

NB官方的Itanium ABI網址是http://www.codesourcery.com/cxx-abi/ –

回答

0

想法是,C3::operator new(sizeof(class))的優化版本,後面是C1,即預先內聯版本。 GCC必須創建它以防其他編譯器使用它。這顯然取決於內聯決策,這通常是不平凡的。

+1

其實,上次我看gcc *並沒有創建一個C3符號。 – aschepler

+0

嗯,這將不會被鏈接到一個對象文件,它確實期望它。 ABI的想法是您可以鏈接二進制文件。 – MSalters

+0

有沒有辦法產生C3? – yonutix

相關問題