[Bug c++/11091] Wrong code in variable initialization
dej@inode.org
gcc-bugzilla@gcc.gnu.org
Thu Jun 5 02:53:00 GMT 2003
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11091
------- Additional Comments From dej@inode.org 2003-06-05 02:53 -------
My observations are taken with no optimization. Sample compile
line:
/usr/local/gcc322/bin/gcc -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\"
-DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"xeda\"
-DVERSION=\"0.1\" -I. -I. -I.. -I../util/ -I../../boost/ -g -c -o DBElabNet.o `test
-f DBElabNet.cpp || echo './'`DBElabNet.cpp
I would have loved to submit a smaller example. Trivial test cases work properly: the
smart pointer is initialized to zero. It is only this large case that fails (and perhaps
only in this method; I have not investigated other declarations to see if the problem
occurs multiple times).
As far as the code goes, I still believe it is wrong:
86b: 83 ec 40 sub $0x40,%esp
86e: 8b 5d 14 mov 0x14(%ebp),%ebx
871: 8b 45 08 mov 0x8(%ebp),%eax
874: 89 04 24 mov %eax,(%esp,1)
877: e8 fc ff ff ff call 878
<_ZNK14DBInstantiator9findChildE5GCPtrI6DBNameE9DBObjType+0x12>
The variable is stored on the stack, not in a register. At least that's what GDB tells
me when I print &obj. For the code above, obj is located in the stack frame at offset
0x8(%ebp). It is the CONTENTS of this location that is pushed onto the stack and which
forms the argument to the constructor. Said contents are of course uninitialized.
If the mov at line 871 were replaced with lea, then the code would work correctly. I
actually see lea used in code sequence in a different function in the same file in my
working sources.
Am I missing something here? If you want, give me your phone number and I can call you
tomorrow to discuss this further.
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
More information about the Gcc-bugs
mailing list