From: Mathieu Desnoyers Date: Tue, 15 Jun 2021 19:28:24 +0000 (-0400) Subject: Fix: x86 and s390 uatomic: __hp() macro warning with gcc 11 X-Git-Tag: v0.14.0~74 X-Git-Url: https://git.liburcu.org/?p=urcu.git;a=commitdiff_plain;h=835b9ab3ca3777fe42e37e92096226ebd19ca75b;hp=835b9ab3ca3777fe42e37e92096226ebd19ca75b Fix: x86 and s390 uatomic: __hp() macro warning with gcc 11 The __hp() macro used in the x86 and s390 uatomic code generates the following warning with gcc-11: In file included from ../include/urcu/uatomic.h:27, from ../include/urcu/static/wfcqueue.h:35, from ../include/urcu/wfcqueue.h:133, from workqueue.c:39: workqueue.c: In function ‘workqueue_thread’: ../include/urcu/uatomic/x86.h:155:17: warning: array subscript ‘struct __uatomic_dummy[0]’ is partly outside array bounds of ‘struct cds_wfcq_tail[1]’ [-Warray-bounds] 155 | __asm__ __volatile__( | ^~~~~~~ workqueue.c:184:38: note: while referencing ‘cbs_tmp_tail’ 184 | struct cds_wfcq_tail cbs_tmp_tail; | ^~~~~~~~~~~~ The (previously undocumented) reason for this macro is to allow passing the "void *" parameter as "m" or "+m" operand to the inline assembly. That motivation was explained in commit 53b8ed6836363 ("s390 uatomic arch fix"). The out of bound access is detected by gcc because struct __uatomic_dummy's length is quite large: an array of 10 unsigned long, which is larger than the size pointed to by the void pointer. So rather than using a fixed-size type, cast to a structure containing an array of characters of a size matching the @addr input argument. While we are at it and digging out git archeology, properly document the __hp() macro for posterity. Signed-off-by: Mathieu Desnoyers Change-Id: I785e30661efe48be1806664a1a14fd3c9fdb0a32 ---