This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: temp obj created by compiler


Hi Jonathan & Everyone,

Thanks for your reply. Yes, as you pointed out, it
will create only 2 temporaries as below:
X a(1);
 	sub	r3, fp, #16
	mov	r0, r3
	mov	r1, #1
	bl	X::X[in-charge](int)

 a = f(a);
	sub	r3, fp, #24
	sub	r2, fp, #16
	mov	r0, r3
	mov	r1, r2
	bl	X::X[in-charge](X const&)
	sub	r2, fp, #24
	sub	r3, fp, #20
	mov	r0, r3
	mov	r1, r2
	bl	f(X)
	sub	r3, fp, #20
	mov	r0, r3
	bl	X::~X [in-charge]()=>dtor for temp1
	sub	r3, fp, #24
	mov	r0, r3
	bl	X::~X [in-charge]()=>dtor for temp2
	sub	r3, fp, #16
	mov	r0, r3
	bl	X::~X [in-charge]()=>dtor for a

What i want to know is how to find what are the
temporaries inserted by the compl.
I tried looking into the ABI but couldn't get much
help. Is there any way i can figure out the
temporaries  inserted by the compl.
Looking forward for more help. :)

Best regards,
San



--- Jonathan Wakely <cow@compsoc.man.ac.uk> wrote:

> On Thu, Feb 10, 2005 at 01:49:44PM +0000, Jonathan
> Wakely wrote:
> 
> > > a = f(a);  //this will create 4 temorary objects
> > 
> > Why?  I think this will only create two
> temporaries.
> > 
> > One when a is copied to the "x" parameter of f()
> and one when "x" is
> > copied to the return value;
> 
> to be clear, "x" isn't a true temporary as it has a
> name, but it is
> created and destroyed during the execution of f(),
> which is what I
> assume you meant.
> 
> jon
> 
> -- 
> "Keep away from people who try to belittle your
> ambitions. Small people 
>  always do that, but the really great make you feel
> that you, too, can
>  become great."
> 	- Mark Twain
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]