This is the mail archive of the gcc-help@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]

change in the way a struct is returned from gcc 2.95 gcc 3.3.1


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


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