https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128402
Bug ID: 128402
Summary: [16/17 Regression] Misaligned movaps for _BitInt(129)
temporary causes runtime SIGSEGV
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: jeffchen006 at gmail dot com
Target Milestone: ---
GCC 17.0.0 20261102 (experimental), revision
7eb405c3d119d4fc84b31f21d6499069fbfedad8
Target: x86_64-linux-gnu; reproduced on Compiler Explorer.
Configure options (installation paths and packaging metadata omitted):
--build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
--disable-bootstrap --enable-multiarch --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --enable-clocale=gnu
--enable-languages=c,c++,fortran,ada,objc,obj-c++,go,d,rust,m2,cobol,algol68
--enable-ld=yes --enable-gold=yes --enable-libstdcxx-time=yes
--enable-linker-build-id --enable-lto --enable-plugins --enable-threads=posix
The testcase is complete and has no #include dependencies. Compile and run with
no command-line arguments.
Testcase (bug-003.c):
int printf(const char *, ...);
_BitInt(129) x, y;
int c, n = 1;
void f(_BitInt(129) a, _BitInt(129) b)
{
if (n--) {
x = 0;
f(c ? x : 0x10000000000000001uwb, y);
}
y += a;
}
int main(void)
{
f(0, 0);
printf("ok\n");
return 0;
}
Reproduction commands:
gcc -std=gnu2x -Wall -Wextra -O0 bug-003.c -o o0
./o0
gcc -std=gnu2x -Wall -Wextra -O3 bug-003.c -o o3
./o3
Expected: ok
Actual with -O0: ok
Actual with -O3: SIGSEGV (exit status 139)
Compiler diagnostic (source filename normalized):
bug-003.c: In function 'f':
bug-003.c:6:37: warning: unused parameter 'b' [-Wunused-parameter]
6 | void f(_BitInt(129) a, _BitInt(129) b)
| ~~~~~~~~~~~~~^
The failure also persists with:
-O3 -fno-strict-aliasing -fwrapv -fno-aggressive-loop-optimizations
Analysis and additional checks:
The executable built at -O0 prints ok and exits normally; -O3 compiles
successfully, but the resulting executable terminates with SIGSEGV. Compiler
Explorer GCC 15.3 prints ok at -O3, whereas GCC 16.2 and current trunk crash.
The executed path is finite: n starts at 1, the recursive call sees n == 0, and
the _BitInt arithmetic is representable. This is a runtime crash of the
compiled program, not an internal compiler error.
In current-trunk assembly, main subtracts 104 from the entry stack pointer,
making %rsp 16-byte aligned under the x86-64 SysV ABI, then executes:
movaps %xmm0, 24(%rsp)
The destination is only 8-byte aligned. This is consistent with the runtime
alignment fault. There is also an aligned load from a corresponding unaligned
slot later in main.
-O3 -fno-tree-sra prints ok. The earlier bisection supplied with the original
testcase points to 1d0a0173cd3 (SRA change for PR121527); this bisection was
not repeated in the fresh verification.
The only -Wall -Wextra warning is the unused parameter b. With ASan+UBSan
enabled at -O3, this snapshot also crashes and ASan reports a SEGV in f. Thus
the reproducer is NOT being described as sanitizer-clean.