Fix: change method used by _rcu_dereference to strip type constness
[urcu.git] / include / urcu / static / pointer.h
index 465a6101bcb12b5708ccfb90334b00969bf6b0c3..c276e68ef770c13c6d6b0c1cf79b9bd055ae4ee0 100644 (file)
@@ -93,12 +93,15 @@ extern "C" {
 /*
  * If p is const (the pointer itself, not what it points to), using
  * __typeof__(p) would declare a const variable, leading to
 /*
  * 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.
+ * -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__ ({                                          \
  */
 #ifdef __URCU_DEREFERENCE_USE_ATOMIC_CONSUME
 # define _rcu_dereference(p) __extension__ ({                                          \
-                               __typeof__(p + 0) _________p1;                          \
+                               __typeof__(__extension__ ({                             \
+                                       __typeof__(p) _________p0 = { 0 };              \
+                                       _________p0;                                    \
+                               })) _________p1;                                        \
                                __atomic_load(&(p), &_________p1, __ATOMIC_CONSUME);    \
                                (_________p1);                                          \
                        })
                                __atomic_load(&(p), &_________p1, __ATOMIC_CONSUME);    \
                                (_________p1);                                          \
                        })
This page took 0.022727 seconds and 4 git commands to generate.