https://gcc.gnu.org/g:98bc42f456d04d71fe9b2b55fa7c7ad415367bbc
commit r15-9898-g98bc42f456d04d71fe9b2b55fa7c7ad415367bbc Author: Jakub Jelinek <ja...@redhat.com> Date: Tue Jul 1 19:37:39 2025 +0200 testsuite: Fix up gcc.target/powerpc/builtin_altivec_tr_stxvr_runnable.c test (test UB) [PR120919] In my reading of the test and the instructions emitted by the builtins, it invokes UB 4 times, each time overwriting one byte after some variable (sc, then ss, then si and then sll). If we are lucky, like at -O0 -mcpu=power10, there is just padding there or something that doesn't make the tests fail, if unlucky like with -O0 -mcpu=power10 -fstack-protector-strong, &sc + 1 == &expected_sc and so it overwrites the expected_sc variable. The test fails when testing with RUNTESTFLAGS="--target_board=unix/'{,-fstack-protector-strong}'" on power10. The following patch fixes that by using arrays of 2 elements, so that the overwriting of 1 byte happens to the part of the same variable. 2025-07-01 Jakub Jelinek <ja...@redhat.com> PR testsuite/120919 * gcc.target/powerpc/builtin_altivec_tr_stxvr_runnable.c (main): Change sc, ss, si and sll vars from scalars to arrays of 2 elements, initialize and test just the first one though. (cherry picked from commit f5282f7402939fdec910ef3743d38edac864eec8) Diff: --- .../powerpc/builtin_altivec_tr_stxvr_runnable.c | 40 +++++++++++----------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/gcc/testsuite/gcc.target/powerpc/builtin_altivec_tr_stxvr_runnable.c b/gcc/testsuite/gcc.target/powerpc/builtin_altivec_tr_stxvr_runnable.c index 4b9043797327..fab7a529e39c 100644 --- a/gcc/testsuite/gcc.target/powerpc/builtin_altivec_tr_stxvr_runnable.c +++ b/gcc/testsuite/gcc.target/powerpc/builtin_altivec_tr_stxvr_runnable.c @@ -27,10 +27,10 @@ int main () { int i; signed long sl; - signed char sc, expected_sc; - signed short ss, expected_ss; - signed int si, expected_si; - signed long long int sll, expected_sll; + signed char sc[2], expected_sc; + signed short ss[2], expected_ss; + signed int si[2], expected_si; + signed long long int sll[2], expected_sll; signed char *psc; signed short *pss; signed int *psi; @@ -41,56 +41,56 @@ main () { printf("Data to store [%d] = 0x%llx %llx\n", i, val.ull[1], val.ull[0]); #endif - psc = ≻ - pss = &ss; - psi = &si; - psll = &sll; + psc = &sc[0]; + pss = &ss[0]; + psi = &si[0]; + psll = &sll[0]; sl = 1; - sc = 0xA1; + sc[0] = 0xA1; expected_sc = 0xA1; __builtin_altivec_tr_stxvrbx (store_data, sl, psc); - if (expected_sc != sc & 0xFF) + if (expected_sc != sc[0] & 0xFF) #if DEBUG printf(" ERROR: Signed char = 0x%x doesn't match expected value 0x%x\n", - sc & 0xFF, expected_sc); + sc[0] & 0xFF, expected_sc); #else abort(); #endif - ss = 0x52; + ss[0] = 0x52; expected_ss = 0x1752; __builtin_altivec_tr_stxvrhx (store_data, sl, pss); - if (expected_ss != ss & 0xFFFF) + if (expected_ss != ss[0] & 0xFFFF) #if DEBUG printf(" ERROR: Signed short = 0x%x doesn't match expected value 0x%x\n", - ss, expected_ss) & 0xFFFF; + ss[0], expected_ss) & 0xFFFF; #else abort(); #endif - si = 0x21; + si[0] = 0x21; expected_si = 0x54321721; __builtin_altivec_tr_stxvrwx (store_data, sl, psi); - if (expected_si != si) + if (expected_si != si[0]) #if DEBUG printf(" ERROR: Signed int = 0x%x doesn't match expected value 0x%x\n", - si, expected_si); + si[0], expected_si); #else abort(); #endif - sll = 0x12FFULL; + sll[0] = 0x12FFULL; expected_sll = 0xdcba9876543217FF; __builtin_altivec_tr_stxvrdx (store_data, sl, psll); - if (expected_sll != sll) + if (expected_sll != sll[0]) #if DEBUG printf(" ERROR: Signed long long int = 0x%llx doesn't match expected value 0x%llx\n", - sll, expected_sll); + sll[0], expected_sll); #else abort(); #endif