public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Martin Liska <marxin@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-5954] testsuite: fix ASAN errors
Date: Tue, 14 Dec 2021 14:49:47 +0000 (GMT)	[thread overview]
Message-ID: <20211214144947.360263857815@sourceware.org> (raw)

https://gcc.gnu.org/g:0dfb1bd94454ccae6d3c77799e209fab7711ed93

commit r12-5954-g0dfb1bd94454ccae6d3c77799e209fab7711ed93
Author: Martin Liska <mliska@suse.cz>
Date:   Tue Dec 14 15:43:16 2021 +0100

    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:
---
 gcc/testsuite/gcc.target/i386/avx2-psraq-1.c | 2 +-
 gcc/testsuite/gcc.target/i386/m128-check.h   | 8 ++++----
 gcc/testsuite/gcc.target/i386/sse2-psraq-1.c | 2 +-
 gcc/testsuite/gcc.target/i386/sse4_2-check.h | 1 +
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/gcc/testsuite/gcc.target/i386/avx2-psraq-1.c b/gcc/testsuite/gcc.target/i386/avx2-psraq-1.c
index e9051bf9fcb..96e5c4ccf76 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 c468eac6a13..e90e1f02d32 100644
--- a/gcc/testsuite/gcc.target/i386/m128-check.h
+++ b/gcc/testsuite/gcc.target/i386/m128-check.h
@@ -1,6 +1,10 @@
 #include <stdio.h>
 #include <xmmintrin.h>
 
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(A) (sizeof (A) / sizeof ((A)[0]))
+#endif
+
 #ifdef __SSE2__
 #include <emmintrin.h>
 
@@ -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 9a08ee4f7fa..dfb0bb8435f 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 d10e6c7d7e2..c33cd1b4986 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 <stdio.h>
 #include <stdlib.h>
 
+#include "m128-check.h"
 #include "cpuid.h"
 
 static void sse4_2_test (void);


                 reply	other threads:[~2021-12-14 14:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211214144947.360263857815@sourceware.org \
    --to=marxin@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).