gcc-3.4.1-9, ia64, dist-fc3 buildroot. bash-3.00# cat dbl.c #include <stdio.h> #include <limits.h> int main(int argc, char **argv) { double d = -12.345; long l = (d > LONG_MAX) ? (unsigned long) d : (long) d; printf("%ld\n", l); return 0; } bash-3.00# gcc -Wall dbl.c bash-3.00# ./a.out -9223372036854775808 bash-3.00# gcc -O2 -Wall dbl.c bash-3.00# ./a.out 0 Yes the program is weird and stupid, but it seems to have well-defined behaviour by C99, AFAICT. if the line is changed to, e.g.: long l = (d > LONG_MAX) ? (unsigned long) (puts(""), d) : (long) d; it prints -12, also.
Forgot to mention: the program prints -12 on all our other platforms, as expected.