X-Git-Url: https://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=include%2Furcu%2Fstatic%2Fpointer.h;h=465a6101bcb12b5708ccfb90334b00969bf6b0c3;hp=ca9a2f9836760dd01207508d2615ee9f43d4e555;hb=1e41ec3b07e4f8eb71c3ace758c76a7ad1784c73;hpb=13bf2f5734e6cab159fe7f9b8fcca175aa5f0e81;ds=sidebyside diff --git a/include/urcu/static/pointer.h b/include/urcu/static/pointer.h index ca9a2f9..465a610 100644 --- a/include/urcu/static/pointer.h +++ b/include/urcu/static/pointer.h @@ -90,9 +90,15 @@ 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 `+ 0` 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__(p + 0) _________p1; \ __atomic_load(&(p), &_________p1, __ATOMIC_CONSUME); \ (_________p1); \ })