Quote:
Originally Posted by halfpower
I installed Slackware 10.1 or 10.2 (32 bit)two or three years ago. I've recently installed Ubuntu 9.04 (64 bit).
|
Should I assume you have also switched the programs you are compiling from 32 bit to 64 bit?
Quote:
the compiled programs seem to be behaving unpredictably, as declarations of unused variables is resulting in different output values.
|
The declarations of unused variables probably affects the allocation sequence of used variables.
So you probably have some data clobber whose effect depends on the exact placement of the program's data. Many such data clobbers are likely from recompiling in 64 bit mode a program that made assumptions about pointers and/or size_t that only work in 32 bit.
If you install the right additional packages (32 bit libraries) in Ubuntu, you should be able to get your program compiled and built with -m32 on the 64 bit system. That may help diagnose whether the cause is an error in your program revealed by the switch to 64 bit as opposed to an error in your program revealed by the switch to a newer version of GCC.
If you were skilled at debugging, you could find the problem more directly by using gdb to examine the nature of the seg fault. But if you knew how to do that, I think you wouldn't have posted what you did.
Quote:
The only explanation for this is that there is a bug in G++ 4.3.3.
|
That is nonsense.
Bugs in programs often have no symptoms. You may change something, such as the version of GCC, and your symptom free bug may suddenly have severe symptoms.
The fact that your program had no symptoms in an earlier version of GCC does not mean your program didn't have a bug that causes the present symptom.
If you changed from 32 bit to 64 bit, that is more likely to be what revealed the "bug". But any change can reveal a bug.