Stack pointer gets messed up. :)

Kenton Varda temporal@visi.com
Wed Jun 23 04:17:00 GMT 1999


Bug found under Red Hat Linux 6.0 w/ECGS 2.91.66.
Just "g++ ecgsbug.cpp" will recreate the bug.

After multiplying class transformation and class vector in main(),
the program calls vector::operator=(const vector& other).
However, "this" and "other" were passed as incorrect pointers.
During one debug, "this" should have been 0xbffffb9c, but was
0xbf7ff744 instead. "&other" should have been 0xbffffb38, but was
0xbf7ff6e0.  So, both were offset by 0x00800458.  By manually
setting these pointers back to their correct values, I was able
to obtain the correct results from that function.  Unfortunately,
the whole program was still offset when it returned to the main
function, and it incorrectly referenced the local variable "v".
So, this appears to be the result of the stack pointer getting messed
up somehow...  (can you tell I don't know what I'm talking about? :)
Compiler bug?  MSVC5 (ewww :) correctly compiled and ran this
same program.



More information about the Gcc-bugs mailing list