Hi all, I have a piece of scientific fortran 77 code that has been developed over the last 25 years or so. It is compiled with gfortran 4.4.1 on SuSE 11.1, on an Intel i7 (i.e. quad-core x86_64). No random number generators are used, so the program should be deterministic. However, I have discovered several test cases where the program was producing different output each time it was run. This implies a memory error, of course. However, I have run the code with -fbounds-check, and have run through Valgrind, and discover no errors. Previously, I had been running the code with -O2. Fortuitously, I discovered that compiling with -O made the bug disappear on my test cases. I realise that this is much more likely to reveal a memory error than a compiler bug. I am unable to produce a test case due to the size and complexity of the program. I have two questions: 1) Are there any compiler bugs relevant to the -O2 switches that are known to have been fixed since 4.4.1 which might solve my problem? 2) Bizzarely, if I manually enable all the flags that appear to be associated with -O2, the bug does not appear, and the program seems to run slower. Why is it that -O + -O2 flags does not equal -O2? Here are my compilation flags: -O -Wall -g -fgcse -fgcse-lm -fthread-jumps -falign-functions -falign-jumps -falign-loops -falign-labels -fcaller-saves -fcrossjumping -fcse-follow-jumps -fcse-skip-blocks -fcse-skip-blocks -fdelete-null-pointer-checks -finline-small-functions -findirect-inlining -foptimize-sibling-calls -fstrict-aliasing -fstrict-overflow -freorder-blocks -freorder-functions -falign-functions -falign-jumps -falign-loops -falign-labels -fregmove -ftree-vrp -ftree-pre -fpeephole2 -fschedule-insns2 -fsched-interblock -fsched-spec -frerun-cse-after-loop -fexpensive-optimizations -ftree-switch-conversion The only flag not there from the -O2 list is -fschedule-insns, If I try to enable that, I get the following error message: ---snip--- vpfit.f: In function ‘vp_settied’: vpfit.f:911: error: unable to find a register to spill in class ‘DREG’ vpfit.f:911: error: this is the insn: (insn 129 137 130 16 vpfit.f:897 (parallel [ (set (reg:SI 0 ax [104]) (div:SI (reg:SI 2 cx [orig:106 k ] [106]) (mem/s/c:SI (symbol_ref:DI ("vpc_noppsys_") <var_decl 0x2ad30d61d500 vpc_noppsys>) [6 vpc_noppsys.noppsys+0 S4 A128]))) (set (reg:SI 2 cx [105]) (mod:SI (reg:SI 2 cx [orig:106 k ] [106]) (mem/s/c:SI (symbol_ref:DI ("vpc_noppsys_") <var_decl 0x2ad30d61d500 vpc_noppsys>) [6 vpc_noppsys.noppsys+0 S4 A128]))) (clobber (reg:CC 17 flags)) ]) 354 {*divmodsi4_nocltd} (expr_list:REG_DEAD (reg:SI 2 cx [orig:106 k ] [106]) (expr_list:REG_UNUSED (reg:SI 2 cx [105]) (expr_list:REG_UNUSED (reg:CC 17 flags) (nil))))) vpfit.f:911: confused by earlier errors, bailing out ---snip-- Thanks for your help, Julian