Re: temp obj created by compiler

2005-02-11 Thread san san
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 <[EMAIL PROTECTED]> wrote:

> On Thu, Feb 10, 2005 at 01:49:44PM +, 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 


Re: temp obj created by compiler

2005-02-11 Thread san san
Hi Jon,

Thanks again for replying. Let me clarify my problem:
I have an assembly file of a .cpp file, from the
assembly file i want to figure out where the compl has
created temp objects.
For this i thought of looking for copy-ctor becuase
temp obj. are created using copy-ctors. I am not sure
if there is any other way by which i can figure out
that.
I hope i am clear this time :).

Regards,
San





--- Jonathan Wakely <[EMAIL PROTECTED]> wrote:

> On Fri, Feb 11, 2005 at 05:44:52AM -0800, san san
> wrote:
> 
> > Hi Jonathan & Everyone,
> 
> Hello again San,
> 
> > What i want to know is how to find what are the
> > temporaries inserted by the compl.
> 
> I don't think I understand your question properly.
> 
> > 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.
> 
> The compiler creates and destroys objects as
> dictated by the C++
> standard. If the language rules require a temporary
> object to be
> created then the compiler will create one.
> 
> Your code passes objects by value, not by reference,
> which causes
> objects to be created and destroyed.
> 
> Apologies if I've misunderstood you,
> 
> jon
> 
> -- 
> "Political satire became obsolete when Henry
> Kissinger was awarded the
>  Nobel Prize."
>   - Tom Lehrer
> 


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


Re: temp obj created by compiler

2005-02-11 Thread san san
Thanks Jon,

Can anyone throw more light on this.

Regards,
Sanjiv
--- Jonathan Wakely <[EMAIL PROTECTED]> wrote:

> On Fri, Feb 11, 2005 at 06:08:55AM -0800, san san
> wrote:
> 
> > Hi Jon,
> > 
> > Thanks again for replying. Let me clarify my
> problem:
> > I have an assembly file of a .cpp file, from the
> > assembly file i want to figure out where the compl
> has
> > created temp objects.
> 
> Ah, I see what you mean now - but I probably can't
> help you with that.
> 
> > For this i thought of looking for copy-ctor
> becuase
> > temp obj. are created using copy-ctors. I am not
> sure
> > if there is any other way by which i can figure
> out
> > that.
> 
> Not necessarily true, temporaries might be created
> by any non-explicit
> constructor, consider
> 
> struct A {
>   A(int);
> };
> 
> void f(const A&);
> 
> f(0);   // creates a temporary A using A::A(int)
> 
> jon
> 
> -- 
> "It is always the best policy to tell the truth,
> unless, of course, you 
>  are an exceptionally good liar."
>   - Jerome K. Jerome
> 




__ 
Do you Yahoo!? 
Yahoo! Mail - Easier than ever with enhanced search. Learn more.
http://info.mail.yahoo.com/mail_250