Code like: #include <stdatomic.h> _Atomic const int ai; int aiGet(void){ return atomic_load(&ai); } has been raising "warning: assignment of read-only location". This is due to `__typeof__ (*ptr) tmp;` not rvalue-converting the target type.
Unified · Split
| @@ -100,7 +100,7 @@ typedef struct { · 99 unmodified lines | |||
| 100 | __val; }) | 100 | __val; }) |
| 101 | #define atomic_load_explicit(object, order) \ | 101 | #define atomic_load_explicit(object, order) \ |
| 102 | ({ __typeof__ (object) ptr = (object); \ | 102 | ({ __typeof__ (object) ptr = (object); \ |
| 103 | __typeof__ (*ptr) tmp; \ | 103 | __typeof__ ((void)0,*ptr) tmp; \ |
| 104 | __atomic_load (ptr, &tmp, (order)); \ | 104 | __atomic_load (ptr, &tmp, (order)); \ |
| 105 | tmp; \ | 105 | tmp; \ |
| 106 | }) | 106 | }) |