no see copy-constructor in output of nm
For the following code:
class Integer
{
public :
Integer ( int i ) : i_ ( i ) {}
private :
int i_ ;
} ;
int main ( void )
{
Integer a ( 1 ) ;
Integer c ( a ) ;
}I do: g++ -c and then run nm -C on the object file. I get only:
00000000 W Integer::Integer(int)
U __gxx_personality_v0
00000000 T main
Why do I not see the signature of the copy constructor Integer::Integer(const Integer&) in the symbols list even though it is automatically created?
Also, why do I not see i_, a and c and the name of the class Integer itself? Are they not also symbols?
Shriramana Sharma.
Quoted 15 lines · Shriramana Sharma
class Integer
{
public :Integer ( int i ) : i_ ( i ) {} private : int i_ ; } ; int main ( void ) { Integer a ( 1 ) ; Integer c ( a ) ; }I do: g++ -c and then run nm -C on the object file. I get only:
Quoted 7 lines
00000000 W
Integer::Integer(int)
U__gxx_personality_v0
00000000 T mainWhy do I not see the signature of the copy constructor
Integer::Integer(const Integer&)in the symbols list even though it is automatically created?
Because it's inlined. The default copy constructor just copies the raw data.
Quoted 2 lines
Also, why do I not see i_, a and c and the name of the class Integer itself? Are they not also symbols?
a and c are automatic variables, which are created on the stack whenever the function is called and destroyed when it returns. They don't exist within the executable.
i_ is a structure field; it doesn't have an existence separate from the object to which it belongs.
Signature · 1 line
Glynn Clements <[email protected]>