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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux