X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=include%2Furcu%2Fstatic%2Fpointer.h;h=9e46a5769c92fc99142adf55989aa0d37581647c;hb=fada682f0d6e680f18e3243aa0af607dfafcbd32;hp=ca9a2f9836760dd01207508d2615ee9f43d4e555;hpb=3abcdbd14d1b9291f06a4a4bbca313fcfbe5452b;p=urcu.git diff --git a/include/urcu/static/pointer.h b/include/urcu/static/pointer.h index ca9a2f9..9e46a57 100644 --- a/include/urcu/static/pointer.h +++ b/include/urcu/static/pointer.h @@ -90,9 +90,18 @@ extern "C" { # define __URCU_DEREFERENCE_USE_ATOMIC_CONSUME #endif +/* + * If p is const (the pointer itself, not what it points to), using + * __typeof__(p) would declare a const variable, leading to + * -Wincompatible-pointer-types errors. Using the statement expression + * makes it an rvalue and gets rid of the const-ness. + */ #ifdef __URCU_DEREFERENCE_USE_ATOMIC_CONSUME # define _rcu_dereference(p) __extension__ ({ \ - __typeof__(p) _________p1; \ + __typeof__(__extension__ ({ \ + __typeof__(p) __attribute__((unused)) _________p0 = { 0 }; \ + _________p0; \ + })) _________p1; \ __atomic_load(&(p), &_________p1, __ATOMIC_CONSUME); \ (_________p1); \ })