https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69104
Bug ID: 69104 Summary: invalid atomic memory order not diagnosed Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- Gcc silently accepts invocations of C11 atomic operations with an invalid memory_order argument. For example, it doesn't diagnose any of the invalid calls in the test case below (and emits fences for most). In contrast, Clang issues "warning: memory order argument to atomic operation is invalid [-Watomic-memory-ordering]" for each of them and treats them as no-ops. $ cat z.c && /home/msebor/build/gcc-trunk-svn/gcc/xgcc -B/home/msebor/build/gcc-trunk-svn/gcc -O2 -S -Wall -Wextra -Wpedantic -o/dev/null z.c #include <stdatomic.h> /* atomic_store_explicit(): The order argument shall not be memory_order_acquire, memory_order_consume, nor memory_order_acq_rel. */ void store_consume (_Atomic int *i) { atomic_store_explicit (i, 0, memory_order_consume); } void store_acquire (_Atomic int *i) { atomic_store_explicit (i, 0, memory_order_acquire); } void store_acq_rel (_Atomic int *i) { atomic_store_explicit (i, 0, memory_order_acq_rel); } /* atomic_load_explicit(): The order argument shall not be memory_order_release nor memory_order_acq_rel. */ int load_consume (_Atomic int *i) { return atomic_load_explicit (i, memory_order_release); } int load_acq_rel (_Atomic int *i) { return atomic_load_explicit (i, memory_order_acq_rel); }