I have a reproducible test case which shows that GCC 4.5 (20091112)
doesn't compile a certain quicksort implementation correctly. It runs
fine, but the sorting is plain wrong when trying to optimize with -O1 or
higher. I have made a reproducible test case. There might be something
wrong with the quicksort implementation itself, but it compiles and runs
fine when not optimizing anything with GCC 4.5. It also runs, and
executes correctly on 4.3 and 4.4 with all optimizations applied.
The code in question is here:
http://pastebin.com/m270ad2a5
Output when compiling with
gcc-4.5 -o qsort qsort.c -O
http://pastebin.com/m44c8f6f2
Output with
gcc-4.5 -o qsort qsort.c
http://pastebin.com/m6ee486a0
Output with
gcc-4.4 -o qsort qsort.c $CRAZYSTUFF_HERE
http://pastebin.com/m78d55249