https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124827
Bug ID: 124827
Summary: [16 Regression] -Winvalid-memory-model
-fsanitize=thread no longer shows warning about
invalid model for __atomic_compare_exchange
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
CC: aaron.puchert at sap dot com, dimitar.yordanov at sap dot
com,
unassigned at gcc dot gnu.org
Depends on: 124822
Target Milestone: ---
The following code:
```
#include <atomic>
std::atomic<int> x;
void test() {
int y = 0;
x.compare_exchange_weak(y, 0, std::memory_order_relaxed,
std::memory_order_release);
}
```
Used to correctly warn in GCC 15 with `-Winvalid-memory-model -fsanitize=thread
-O2`. But now in GCC 16+, GCC does not because waccess2 seems limited and
waccess3 does not the __tsan variants.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124822
[Bug 124822] -Winvalid-memory-model warning only appears with -fsanitize=thread
with __atomic_compare_exchange