https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101953
Bug ID: 101953 Summary: bug on the default cast operator from double to unsigned short Product: gcc Version: 8.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: mlwmohawk at gmail dot com Target Milestone: --- markw@snoopy:~$ gcc --version gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0 markw@snoopy:~$ ./badpi -32000 vs -32000 On Raspberry PI: pi@raspberrypi:~ $ gcc --version gcc (Raspbian 8.3.0-6+rpi1) 8.3.0 pi@raspberrypi:~ $ ./badpi 0 vs -32000 This is the code: #include <stdio.h> #include <stdint.h> #include <math.h> int main(int argc, char **argv) { uint32_t foo; int bar; double val = -32000; bar = ceil(val); foo = ceil(val); printf("%d vs %d\n", foo, bar); } gcc -Wall -o badpi badpi.c -lm