In my program I use recursive quick-sort, which is apparently miscompiled by my gcc (Fedora 8, x86_64), when I use -O3 or -O2 -finline-functions. With these options, the data get out of the qsort routine only partially sorted. With -O2 it is OK, and when I add a debugging printf() at the end of the qsort routine (thus disabling the tail-call recursion), it also works (even with -O3 or -O2 -finline-functions).
The test program is at http://www.fi.muni.cz/~kas/data/sorttest.c - try to compile it and run on 64-bit x86_64 system (it is non-portable, but it is a design decision) with -O2 and with -O3. Then uncomment the debugging code
near the end of the file, and try it again.
It is more than unportable, it contains undefined code as you violate C/C++ aliasing rules:
d = *(unsigned long *)e1;
*(unsigned long *)e1 = *(unsigned long *)e2;
*(unsigned long *)e2 = d;
You are accessing a bucket_entry_t as unsigned long.
*** This bug has been marked as a duplicate of 21920 ***
Interesting. When rewritten to use union, it works even with -O3. Thanks!