Silvio a Beccara wrote:
when compiling a program with optimisation option -O3 sometimes everything works fine, some others the program crashes for no reason. Recompiling without -O3 eliminates the problem.
I use GPC version:
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.3/specs gpc version 20020304, based on 2.95.3 20010315 (release)
Any suggestion?
(General question, general advice.)
- If the "sometimes" is really meant so, i.e. doing the exact same thing (e.g., compiling the same source and removing all .gpi files before) crashes sometimes and not other times, it's quite likely a hardware problem. PC hardware is known to often be buggy, especially under heavy load, and compiling with `-O3' is known to cause heavy load and to be quite sensitive to hardware problems. In such cases, reducing the load (e.g., give the machine some breaks), or better cooling, or even "downclocking" the processor might help. See http://www.bitwizard.nl/sig11/.
(My own machine does this sometimes as well, in particular when compiling with `-O3' for a long time -- fortunately not very often, except on hot summer days which is quite a clear indication that it's a thermic problem ...)
- Try to reproduce the crash in a small test and send it. If I can reproduce the crash, I can most likely fix it.
Running GPC with `--debug-source' will output the source it's compiling so you see where in the code it crashes.
- Try a newer GPC version.
- Get a trace of the crash (enable core dumps, run the crashing compiler again, call `gdb <path/to/gpc1> core' and enter `i s'). With this output, I *might* be able to tell more.
Frank