https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122990
Bug ID: 122990
Summary: double to unsigned long cast yields wrong result for
aarch64
Product: gcc
Version: 15.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: other
Assignee: unassigned at gcc dot gnu.org
Reporter: pkk at spth dot de
Target Milestone: ---
Created attachment 62983
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=62983&action=edit
Sample program to reproduce issue
In the attached program, a double is cast to unsigned long. For the value
-32.0, the result is 0, when the program is compiled targeting aarch64, but
0xffffffffffffffe0, when targeting amd64. I think the result for aarch 64 is
incorrect.
aarch64 (Debian GNU/Linux testing):
philipp@alecto:~$ gcc --version
gcc (Debian 15.2.0-9) 15.2.0
Copyright (C) 2025 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
philipp@alecto:~$ gcc test.c
philipp@alecto:~$ ./a.out
-32.000000 0
amd64 (Debian GNU/Linux testing):
philipp@notebook6:/tmp$ gcc --version
gcc (Debian 15.2.0-9) 15.2.0
Copyright (C) 2025 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
philipp@notebook6:/tmp$ gcc test.c
philipp@notebook6:/tmp$ ./a.out
-32.000000 ffffffffffffffe0