------- Comment #2 from khoaduynguyen at gmail dot com 2008-09-11 21:02 ------- -bash-3.1$ gcc -v Using built-in specs. Target: x86_64-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=x86_64-redhat-linux Thread model: posix gcc version 4.1.2 20070626 (Red Hat 4.1.2-14)
[EMAIL PROTECTED] ~]$ g++ test2.cpp [EMAIL PROTECTED] ~]$ ./a.out In main Base(int), id=0, this=0x7ffff946c390 Base(const Base& k), id=1, this=0x7ffff946c2e0 Derived(const Base&), id=1, this=0x7ffff946c2e0 Test1 -- d.id=0 Base(int), id=2, this=0x7ffff946c3a0 Base(const Base& k), id=3, this=0x7ffff946c260 Derived(const Base&), id=3, this=0x7ffff946c260 Test2 -- d2.id=3 int Derived.test() Base(int), id=4, this=0x7ffff946c1e0 Derived(), id=4, this0x7ffff946c1e0 Test3 -- d3.id=4 int Derived.test() Base(int), id=5, this=0x7ffff946c380 Test4 -- b4.id=5, &b4=0x7ffff946c380 Base(), id=6, this=0x7ffff946c370 Base(), id=7, this=0x7ffff946c360 Base Operator=(const Base&), id=8, this=0x7ffff946c360 Base(const Base& k), id=9, this=0x7ffff946c160 Derived(const Base&), id=9, this=0x7ffff946c160 Test4 -- b4.id=9, &b4=0x7ffff946c160 -- khoaduynguyen at gmail dot com changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|invalid return by value |invalid return by value |optimization |optimization http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37487