public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Kwok Cheung Yeung <kcy@codesourcery.com>
To: Tom de Vries <tdevries@suse.de>, <gcc-patches@gcc.gnu.org>,
	<mikestump@comcast.net>
Cc: <seurer@gcc.gnu.org>, <clyon@gcc.gnu.org>
Subject: [PR96519] Re: [PATCH][testsuite] Add gcc.dg/ia64-sync-5.c
Date: Tue, 11 Aug 2020 19:53:46 +0100	[thread overview]
Message-ID: <cfd7ab05-7570-bc9b-f243-dcff1be1e1ed@codesourcery.com> (raw)
In-Reply-To: <20200806122351.GA20360@delia>

[-- Attachment #1: Type: text/plain, Size: 776 bytes --]

Hello

On 06/08/2020 1:23 pm, Tom de Vries wrote:
 > +static char AC[4];
 > +static char init_qi[4] = { -30,-30,-50,-50 };
 > +static char test_qi[4] = { -115,-115,25,25 };
 > +
 > +static void
 > +do_qi (void)
 > +{
 > +  if (__sync_val_compare_and_swap(AC+0, -30, -115) != -30)
 > +    abort ();

If 'char' is unsigned by default, then init_qi will contain { 226, 226, 206, 
206} and test_qi { 141, 141, 25, 25 }, which will result in the comparison 
against -30 failing when the previous value of AC[0] is implicitly promoted to 
signed int. This can be fixed by making the array element types explicitly signed.

This issue is tracked as issue 96519 on the tracker. I have checked that the 
test now passes on PowerPC and Aarch64. Is the fix okay for trunk?

Thanks

Kwok

[-- Attachment #2: ia64-sync-5_fix.patch --]
[-- Type: text/plain, Size: 1293 bytes --]

commit fc6ac3af45a238da0bd65e020ae6f0f165b57b87
Author: Kwok Cheung Yeung <kcy@codesourcery.com>
Date:   Tue Aug 11 09:41:10 2020 -0700

    Fix gcc.dg/ia64-sync-5.c for architectures with unsigned char as default (PR 96519)
    
    If char is unsigned, then comparisons of the char array elements against
    negative integers in the test will fail as values in the array will always
    be positive, and will remain so when promoted to signed int.
    
    2020-08-11  Kwok Cheung Yeung  <kcy@codesourcery.com>
    
    	PR testsuite/96519
    
    	gcc/testsuite/
    	* gcc.dg/ia64-sync-5.c (AC, init_qi, test_qi): Change element type to
    	signed char.

diff --git a/gcc/testsuite/gcc.dg/ia64-sync-5.c b/gcc/testsuite/gcc.dg/ia64-sync-5.c
index 8b16b29..a3923b0 100644
--- a/gcc/testsuite/gcc.dg/ia64-sync-5.c
+++ b/gcc/testsuite/gcc.dg/ia64-sync-5.c
@@ -14,9 +14,9 @@ extern void abort (void);
 extern void *memcpy (void *, const void *, size_t);
 extern int memcmp (const void *, const void *, size_t);
 
-static char AC[4];
-static char init_qi[4] = { -30,-30,-50,-50 };
-static char test_qi[4] = { -115,-115,25,25 };
+static signed char AC[4];
+static signed char init_qi[4] = { -30,-30,-50,-50 };
+static signed char test_qi[4] = { -115,-115,25,25 };
 
 static void
 do_qi (void)

  parent reply	other threads:[~2020-08-11 18:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-06 12:23 Tom de Vries
2020-08-06 23:55 ` Mike Stump
2020-08-11 18:53 ` Kwok Cheung Yeung [this message]
2020-08-12  8:50   ` [PR96519] " Richard Sandiford

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=cfd7ab05-7570-bc9b-f243-dcff1be1e1ed@codesourcery.com \
    --to=kcy@codesourcery.com \
    --cc=clyon@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=mikestump@comcast.net \
    --cc=seurer@gcc.gnu.org \
    --cc=tdevries@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).