* [PATCH] testsuite: Fix pr108574-3.c failed in arch where sign defaults to unsigned.
@ 2023-01-31 6:10 Xianmiao Qu
2023-01-31 6:57 ` Richard Biener
0 siblings, 1 reply; 3+ messages in thread
From: Xianmiao Qu @ 2023-01-31 6:10 UTC (permalink / raw)
To: gcc-patches, rguenther; +Cc: Xianmiao Qu
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)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] testsuite: Fix pr108574-3.c failed in arch where sign defaults to unsigned.
2023-01-31 6:10 [PATCH] testsuite: Fix pr108574-3.c failed in arch where sign defaults to unsigned Xianmiao Qu
@ 2023-01-31 6:57 ` Richard Biener
2023-01-31 8:51 ` Richard Biener
0 siblings, 1 reply; 3+ messages in thread
From: Richard Biener @ 2023-01-31 6:57 UTC (permalink / raw)
To: Xianmiao Qu; +Cc: gcc-patches
On Tue, 31 Jan 2023, Xianmiao Qu wrote:
> 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.
Whoops - thanks for fixing!
OK.
Richard.
> 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() {
>
--
Richard Biener <rguenther@suse.de>
SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg,
Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman;
HRB 36809 (AG Nuernberg)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] testsuite: Fix pr108574-3.c failed in arch where sign defaults to unsigned.
2023-01-31 6:57 ` Richard Biener
@ 2023-01-31 8:51 ` Richard Biener
0 siblings, 0 replies; 3+ messages in thread
From: Richard Biener @ 2023-01-31 8:51 UTC (permalink / raw)
To: Xianmiao Qu; +Cc: gcc-patches
On Tue, 31 Jan 2023, Richard Biener wrote:
> On Tue, 31 Jan 2023, Xianmiao Qu wrote:
>
> > 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.
>
> Whoops - thanks for fixing!
>
> OK.
I've pushed the fix.
Richard.
> Richard.
>
> > 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() {
> >
>
>
--
Richard Biener <rguenther@suse.de>
SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg,
Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman;
HRB 36809 (AG Nuernberg)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-01-31 8:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-31 6:10 [PATCH] testsuite: Fix pr108574-3.c failed in arch where sign defaults to unsigned Xianmiao Qu
2023-01-31 6:57 ` Richard Biener
2023-01-31 8:51 ` Richard Biener
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).