Consider the following line of the attached test case, where a is double with value 4294967296.0.
double b = (unsigned int)((unsigned long long int)a % 4294967296ULL); Then (unsigned long long int)a % 4294967296ULL should be equal to 0ULL, and therefore b should be 0.0. However, when compiled with -O1 -march=pentium4, b gets the wrong value of 4294967296.0 (the same as a). Note that the error only occurs with -march=pentium4. To compile the testcase: gcc -std=c99 -O1 -march=pentium4 convert-bug.i -o convert-bug gcc -v: Using built-in specs. Target: i686-pc-linux-gnu Configured with: ../gcc/configure --enable-checking=release --prefix=/home/jdemeyer/local CC=gcc-4.1.2 Thread model: posix gcc version 4.4.0 20080916 (experimental) (GCC) -- Summary: Conversion double -> unsigned long long -> unsigned -> double gives wrong results Product: gcc Version: 4.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jdemeyer at cage dot ugent dot be GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37544