Message ID | cfd7ab05-7570-bc9b-f243-dcff1be1e1ed@codesourcery.com |
---|---|
State | New |
Headers | show |
Series | [PR96519] Re: [PATCH][testsuite] Add gcc.dg/ia64-sync-5.c | expand |
Kwok Cheung Yeung <kcy@codesourcery.com> writes: > 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 > > 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. OK, thanks. Richard
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)