From b39da9f6fa7e32c7c8bf6f0bb093fa6331fa5cbb Mon Sep 17 00:00:00 2001 From: Petr Skocik Date: Tue, 28 Apr 2026 08:40:53 +0200 Subject: [PATCH] Fix false warnings with readonly atomics Code like: #include _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. --- include/stdatomic.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/stdatomic.h b/include/stdatomic.h index a03c2ca6..85932a51 100644 --- a/include/stdatomic.h +++ b/include/stdatomic.h @@ -100,7 +100,7 @@ typedef struct { __val; }) #define atomic_load_explicit(object, order) \ ({ __typeof__ (object) ptr = (object); \ - __typeof__ (*ptr) tmp; \ + __typeof__ ((void)0,*ptr) tmp; \ __atomic_load (ptr, &tmp, (order)); \ tmp; \ })