From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59733) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGmW3-0005Xz-9e for qemu-devel@nongnu.org; Thu, 10 May 2018 10:26:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fGmW2-0004O1-BW for qemu-devel@nongnu.org; Thu, 10 May 2018 10:25:55 -0400 Received: from mail-oi0-x241.google.com ([2607:f8b0:4003:c06::241]:39042) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fGmW2-0004Nv-5e for qemu-devel@nongnu.org; Thu, 10 May 2018 10:25:54 -0400 Received: by mail-oi0-x241.google.com with SMTP id n65-v6so1910528oig.6 for ; Thu, 10 May 2018 07:25:54 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <20180508151437.4232-1-richard.henderson@linaro.org> <20180508151437.4232-5-richard.henderson@linaro.org> From: Peter Maydell Date: Thu, 10 May 2018 15:25:26 +0100 Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v3 04/10] tcg: Introduce atomic helpers for integer min/max List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Richard Henderson Cc: QEMU Developers On 8 May 2018 at 19:27, Peter Maydell wrote: > On 8 May 2018 at 18:49, Peter Maydell wrote: >> [weird compiler errors] > > This fixes them: > > --- a/include/qemu/atomic.h > +++ b/include/qemu/atomic.h > @@ -187,7 +187,7 @@ > /* Returns the eventual value, failed or not */ > #define atomic_cmpxchg__nocheck(ptr, old, new) ({ = \ > typeof_strip_qual(*ptr) _old =3D (old); = \ > - __atomic_compare_exchange_n(ptr, &_old, new, false, = \ > + (void)__atomic_compare_exchange_n(ptr, &_old, new, false, = \ > __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); = \ > _old; = \ > }) > > Seems pretty clearly a compiler bug -- rth says newer gcc don't > do this, so presumably fixed upstream somewhere between gcc 5 and 6. Standalone testcase, fwiw: =3D=3D=3Dbegin=3D=3D=3D /* * Weirdly, this compiler will complain about FOO(int8_t) but not * the others: * $ gcc -g -Wall -Wunused-value -o zz9.o -c zz9.c * zz9.c: In function =E2=80=98foo_int8_t=E2=80=99: * zz9.c:12:5: warning: value computed is not used [-Wunused-value] * __atomic_compare_exchange_n(p, exp, des, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); \ * ^ * /tmp/zz9.c:17:1: note: in expansion of macro =E2=80=98FOO=E2=80=99 * FOO(int8_t) * ^ * * This is gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609 */ typedef unsigned char uint8_t; typedef signed char int8_t; #define FOO(TYPE) \ void foo_##TYPE(TYPE *p, TYPE *exp, TYPE *des) { \ __atomic_compare_exchange_n(p, exp, des, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); \ } FOO(int) FOO(uint8_t) FOO(int8_t) =3D=3D=3Dendit=3D=3D=3D thanks -- PMM