public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Xianmiao Qu <cooper.qu@linux.alibaba.com>
To: gcc-patches@gcc.gnu.org, rguenther@suse.de
Cc: Xianmiao Qu <cooper.qu@linux.alibaba.com>
Subject: [PATCH] testsuite: Fix pr108574-3.c failed in arch where sign defaults to unsigned.
Date: Tue, 31 Jan 2023 14:10:38 +0800	[thread overview]
Message-ID: <20230131061038.97059-1-cooper.qu@linux.alibaba.com> (raw)

In the architecture where sign defaults to unsigned, the 'f' will be zero
extended to int type in the expression 'd = ~(f & ~2880764155)', then the
'd' will become -1 wich cause the case to fail.
So it's ok for the architectures where sign defaults to signed like x86,
but failed for the architectures where sign defaults to unsigned like arm
and csky. Change char to signed char to avoid this problem.

gcc/testsuite:
	* gcc.dg/torture/pr108574-3.c (b, f): Change type from char to
	signed char.
---
 gcc/testsuite/gcc.dg/torture/pr108574-3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.dg/torture/pr108574-3.c b/gcc/testsuite/gcc.dg/torture/pr108574-3.c
index 3c9146e31ac..b4d5dae9f80 100644
--- a/gcc/testsuite/gcc.dg/torture/pr108574-3.c
+++ b/gcc/testsuite/gcc.dg/torture/pr108574-3.c
@@ -1,7 +1,7 @@
 /* { dg-do run } */
 
 int a = 3557301289, d;
-char b, f;
+signed char b, f;
 unsigned short c = 241;
 short e, g;
 static void h() {
-- 
2.32.1 (Apple Git-133)


             reply	other threads:[~2023-01-31  6:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-31  6:10 Xianmiao Qu [this message]
2023-01-31  6:57 ` Richard Biener
2023-01-31  8:51   ` Richard Biener

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=20230131061038.97059-1-cooper.qu@linux.alibaba.com \
    --to=cooper.qu@linux.alibaba.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=rguenther@suse.de \
    /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).