public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* change in the way a struct is returned from gcc 2.95 gcc 3.3.1
@ 2005-09-21 10:16 Ravi Krishna
  0 siblings, 0 replies; only message in thread
From: Ravi Krishna @ 2005-09-21 10:16 UTC (permalink / raw)
  To: gcc-help

In short if gcc has to return a struct, it first puts it in the stack
of the callee and then copies it
to the stack of the caller.
I have described the problem at the following blog
http://blog.360.yahoo.com/blog-Soi.8NUyaKJGQJEysjIbGQ--?p=2

I thought it was a bug .. but that may not ne true ..
someone one told me that this was done to support overloaded copy
constructor's in C++,
I am curious to know why this was done. In particular why following
transformation was not done ie given
main ()
{ class X x;
x = foo();
}
X foo () {
return X(2,3); 
}
now the gcc may make x = foo(); => foo( &x);
so foo gets addr of x in main's stack ..
and foo becomes 
void foo( X * x) {
 return x->copy_constructor (2,3 )
 }

in this case no copy from foo's stack to main's stack will be needed ..


Thanks and Regards,
Ravi Krishna

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-09-21 10:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-21 10:16 change in the way a struct is returned from gcc 2.95 gcc 3.3.1 Ravi Krishna

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 read-only IMAP folder(s) and NNTP newsgroup(s).