gcc up to 2.96-60 miscompiles mysql (the file sql/field.cc) when compiled with "-O2" as opposed to "-O1". This results in bad query results.
Created attachment 4553 [details] assembly file with "-O1"
Created attachment 4554 [details] assembly file with -O2
Created attachment 4555 [details] ii file of field.cc
Created attachment 4556 [details] test script for mysql
Created attachment 4557 [details] test script for mysql
That file is full of code dancing around the edge of what is and what is not allowed with -fstrict-aliasing. Either compile that file with -fno-strict-aliasing, or find out which exact routine causes the testcase to fail and I'll tell you whether it is valid C or not (but I assume the latter). Basically, a char pointer can alias with any type, otherwise one should access variables only through compatible types.
Is there a way to turn this on/off inside the source file? Suggestions on how to find which function?
Closing - Jakub found bugs (aliasing) in the Mysql code.
Created attachment 4654 [details] Patch for aliasing problems in mysql