Home >Backend Development >C++ >Why Does the Itanium C ABI Emit Dual Constructor Symbols?
The Itanium C ABI specifies the mangling of function names to include information about their parameters and functionality. Constructor names follow a specific pattern:
_Z | N | <class_name> | <ctor-type> | E | <parameters> prefix | nested | `Thing` | Constructor | end nested | parameters: `int`
The constructor symbols in the library appear twice due to the different types of constructors emitted by GCC:
Even though the class in question has no virtual base classes, GCC still emits both constructors as a byproduct of supporting polymorphism. If polymorphism is not involved, GCC could optimize by emitting only one constructor.
The two constructors have different names because of the C1 and C2 designators in their mangled names, which indicate the different types of construction they perform.
The dual emission of constructor symbols is a consequence of the Itanium C ABI and support for polymorphism, but it can be optimized away by GCC when polymorphism is not used.
The above is the detailed content of Why Does the Itanium C ABI Emit Dual Constructor Symbols?. For more information, please follow other related articles on the PHP Chinese website!