Fedora Account System
Red Hat Associate
Red Hat Customer
bug.c file to reproduce the crash: ---------- #include <string.h> #include <stdint.h> void PyFloat_Pack2(double x, char *data, int le) { _Float16 y = (_Float16)x; if (!le) { uint16_t word; memcpy(&word, &y, 2); word = __builtin_bswap16(word); memcpy(data, &word, 2); } else { memcpy(data, &y, sizeof(_Float16)); } } ---------- GCC crash with -O1 or higher, but it doesn't crash with -O0 or -Og. Reproducible: Always Steps to Reproduce: 1. Create bug.c 2. gcc -O1 -o bug.o -c bug.c Actual Results: Build with gcc 16.2.1 (Fedora package gcc-16.2.1-2.fc44.s390x): ---------- $ gcc -O1 -o bug.o -c bug.c during RTL pass: split1 bug.c: In function ‘PyFloat_Pack2’: bug.c:17:1: internal compiler error: Segmentation fault 17 | } | ^ /usr/libexec/gcc/s390x-redhat-linux/16/cc1 -quiet bug.c -quiet -dumpbase bug.c -dumpbase-ext .c -mtune=z14 -march=z13 -m64 -mzarch -O1 -o /tmp/cc0XMx28.s Please submit a full bug report, with preprocessed source. See <https://bugzilla.redhat.com/> for instructions. Preprocessed source stored into /tmp/cceEi1QY.out file, please attach this to your bugreport. ---------- Expected Results: No crash. Additional Information: $ uname -a Linux fedora-stable 7.2.5-200.fc44.s390x #1 SMP PREEMPT Fri Sep 11 15:37:18 UTC 2026 s390x GNU/Linux $ sudo virt-what ibm_systemz ibm_systemz-zvm
Created attachment 2159407 [details] reproducer.c: C program to reproduce the GCC crash
Sorry, I forgot to mention that, so far, I only reproduced the crash on s390x architecture.
Oh, clang also miscompiles this code (but don't crash): https://github.com/llvm/llvm-project/issues/228151 In Python, I just merged a workaround. Replace: --- _Float16 y = (...); uint16_t word; memcpy(&word, &y, 2); word = __builtin_bswap16(word); memcpy(data, &word, 2); --- with: --- _Float16 y = (...); char buffer[2]; memcpy(buffer, &y, 2); data[0] = buffer[1]; data[1] = buffer[0]; --- See the Python change: https://github.com/python/cpython/commit/c7a79bd2f4d3dd3bcaebd77c47f07d1feabe320a