* no see copy-constructor in output of nm
@ 2007-07-10 16:30 Shriramana Sharma
2007-07-11 15:18 ` Glynn Clements
0 siblings, 1 reply; 2+ messages in thread
From: Shriramana Sharma @ 2007-07-10 16:30 UTC (permalink / raw)
To: Linux C Programming List
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: no see copy-constructor in output of nm
2007-07-10 16:30 no see copy-constructor in output of nm Shriramana Sharma
@ 2007-07-11 15:18 ` Glynn Clements
0 siblings, 0 replies; 2+ messages in thread
From: Glynn Clements @ 2007-07-11 15:18 UTC (permalink / raw)
To: Shriramana Sharma; +Cc: Linux C Programming List
Shriramana Sharma wrote:
> 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?
Because it's inlined. The default copy constructor just copies the raw
data.
> 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.
--
Glynn Clements <glynn@gclements.plus.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-07-11 15:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-10 16:30 no see copy-constructor in output of nm Shriramana Sharma
2007-07-11 15:18 ` Glynn Clements
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).