From: Martin Liska Date: Tue, 14 Dec 2021 14:43:16 +0000 (+0100) Subject: testsuite: fix ASAN errors X-Git-Tag: basepoints/gcc-13~2359 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0dfb1bd94454ccae6d3c77799e209fab7711ed93;p=thirdparty%2Fgcc.git testsuite: fix ASAN errors The tests failed on my machine as they contain out-of-bounds access. gcc/testsuite/ChangeLog: * gcc.target/i386/avx2-psraq-1.c: Use ARRAY_SIZE. * gcc.target/i386/m128-check.h: Move it to the top-level context. * gcc.target/i386/sse2-psraq-1.c: Use ARRAY_SIZE. * gcc.target/i386/sse4_2-check.h: Include the header with ARRAY_SIZE definition. --- diff --git a/gcc/testsuite/gcc.target/i386/avx2-psraq-1.c b/gcc/testsuite/gcc.target/i386/avx2-psraq-1.c index e9051bf9fcbe..96e5c4ccf76b 100644 --- a/gcc/testsuite/gcc.target/i386/avx2-psraq-1.c +++ b/gcc/testsuite/gcc.target/i386/avx2-psraq-1.c @@ -41,7 +41,7 @@ TEST (void) V a = (V) { 0xdeadbeefcafebabeULL, 0x123456789abcdef0ULL, 0x173a74be8a95134cULL, 0x817bae35ac0ebf12ULL }; int i; - for (i = 0; tests[i].n; i++) + for (i = 0; i < ARRAY_SIZE (tests); i++) { V c = tests[i].fn (a); if (c[0] != a[0] >> tests[i].n || c[1] != a[1] >> tests[i].n diff --git a/gcc/testsuite/gcc.target/i386/m128-check.h b/gcc/testsuite/gcc.target/i386/m128-check.h index c468eac6a13c..e90e1f02d32b 100644 --- a/gcc/testsuite/gcc.target/i386/m128-check.h +++ b/gcc/testsuite/gcc.target/i386/m128-check.h @@ -1,6 +1,10 @@ #include #include +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(A) (sizeof (A) / sizeof ((A)[0])) +#endif + #ifdef __SSE2__ #include @@ -66,10 +70,6 @@ typedef union float a[4]; } union128; -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(A) (sizeof (A) / sizeof ((A)[0])) -#endif - #ifdef DEBUG #define PRINTF printf #else diff --git a/gcc/testsuite/gcc.target/i386/sse2-psraq-1.c b/gcc/testsuite/gcc.target/i386/sse2-psraq-1.c index 9a08ee4f7fa5..dfb0bb8435f7 100644 --- a/gcc/testsuite/gcc.target/i386/sse2-psraq-1.c +++ b/gcc/testsuite/gcc.target/i386/sse2-psraq-1.c @@ -41,7 +41,7 @@ TEST (void) V a = (V) { 0xdeadbeefcafebabeULL, 0x123456789abcdef0ULL }; V b = (V) { 0x173a74be8a95134cULL, 0x817bae35ac0ebf12ULL }; int i; - for (i = 0; tests[i].n; i++) + for (i = 0; i < ARRAY_SIZE (tests); i++) { V c = tests[i].fn (a); if (c[0] != a[0] >> tests[i].n || c[1] != a[1] >> tests[i].n) diff --git a/gcc/testsuite/gcc.target/i386/sse4_2-check.h b/gcc/testsuite/gcc.target/i386/sse4_2-check.h index d10e6c7d7e20..c33cd1b49869 100644 --- a/gcc/testsuite/gcc.target/i386/sse4_2-check.h +++ b/gcc/testsuite/gcc.target/i386/sse4_2-check.h @@ -1,6 +1,7 @@ #include #include +#include "m128-check.h" #include "cpuid.h" static void sse4_2_test (void);