Skip to content

Commit b39da9f

Browse files
committed
Fix false warnings with readonly atomics
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.
1 parent 5675177 commit b39da9f

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

include/stdatomic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ typedef struct {
100100
__val; })
101101
#define atomic_load_explicit(object, order) \
102102
({ __typeof__ (object) ptr = (object); \
103-
__typeof__ (*ptr) tmp; \
103+
__typeof__ ((void)0,*ptr) tmp; \
104104
__atomic_load (ptr, &tmp, (order)); \
105105
tmp; \
106106
})

0 commit comments

Comments
 (0)