History

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.

Petr Skocik committed 6 months ago

Commit b39da9f1 parent 56751771 file · +1 −1Browse files

Unified · Split

include/stdatomic.h+1−1
@@ -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 })