The following program: #include <stdio.h> int main(int argc, char **argv) { unsigned int testu32a = 0x506f85f; unsigned long long testu64a = 0x9afa246709018f48ULL;
printf("before: testu64a = %08x%08x, testu32a = %08x\n", (unsigned int)( testu64a >> 32 ), (unsigned int)( testu64a & 0xffffffff ), testu32a ); while ((unsigned long long)testu32a * (unsigned long long)0xffffffff < testu64a) testu64a /= 2; printf("after: testu64a = %08x%08x, testu32a = %08x\n", (unsigned int)( testu64a >> 32 ), (unsigned int)( testu64a & 0xffffffff ), testu32a ); return 0; } When compiled under freebsd 6 using "gcc -o test test.c" gives different results when using gcc 3.4.4 or gcc 4.2.4: Using 3.4.4: before: testu64a = 9afa246709018f48, testu32a = 0506f85f after: testu64a = 04d7d12338480c7a, testu32a = 0506f85f Using 4.2.4: before: testu64a = 9afa246709018f48, testu32a = 0506f85f after: testu64a = 9afa246709018f48, testu32a = 0506f85f The behavior of 4.2.4 has also been seen on a linux gentoo machine running gcc 4.1.2, a 64bit xp machine running gcc 4.2.1, and a regular xp machine running gcc 4.2.1. -- Summary: unsinged long long and while loop evaluation regression? Product: gcc Version: 4.2.4 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: wilbert at jdg dot info GCC build triplet: several GCC host triplet: several GCC target triplet: several http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35885