On 8 May 2018 at 19:27, Peter Maydell <peter.mayd...@linaro.org> wrote: > On 8 May 2018 at 18:49, Peter Maydell <peter.mayd...@linaro.org> 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 = (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: ===begin=== /* * 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 ‘foo_int8_t’: * 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 ‘FOO’ * 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) ===endit=== thanks -- PMM