Integer promotion of a short int and an unsigned short in the same expression seems broken in the system compiler. Fix: Use a different compiler. How-To-Repeat: #include <stdio.h> int main(int argc, char **argv) { short k = 251; unsigned short l = 65535; printf("%hd > %hu = %d\n", k, l, (k > l)); return 0; } > gcc test.c > ./a.out 251 > 65535 = 1
Adding full uname output back in: FreeBSD cracked.hurd.local 9.1-RELEASE-p6 FreeBSD 9.1-RELEASE-p6 #0: Wed Aug 21 20:30:17 UTC 2013 root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC i386
Still present on 9.2-RELEASE-p5
As of FreeBSD 10.x, we are not shipping anymore gcc 4.2.1 by default. There are no plans to update the gcc version included in the 9.x series. Please use clang or gcc from ports which are much more up to date. In FreeBSD 10.1 (with clang), I got $ cc gcc-test.c $ ./a.out 251 > 65535 = 0 $