https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99612
Bug ID: 99612
Summary: Remove "#pragma GCC system_header" from atomic file to
warn on incorrect memory order
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: antoshkka at gmail dot com
Target Milestone: ---
GCC has -Winvalid-memory-model that warns if wrong memory model is used with
atomic
auto ret = a.load(std::memory_order_release); // warning
a.store(10, std::memory_order_acquire); // warning
Unfortunately, that warning does not work by default, because <atomic> header
has a "#pragma GCC system_header" in it.
The only way to get the warning is to use -Wsystem-headers that unleashes all
the warnings from all system headers.
Playground: https://godbolt.org/z/Wca5ef