[LLVMbugs] [Bug 21179] New: No warnings for invalid memory orderings for atomic accesses

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Oct 6 15:36:07 PDT 2014


            Bug ID: 21179
           Summary: No warnings for invalid memory orderings for atomic
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: morisset at google.com
                CC: dgregor at apple.com, jfb at google.com,
                    llvmbugs at cs.uiuc.edu
    Classification: Unclassified

I believe that it is undefined behaviour for an atomic load to have the
memory_order_release or memory_order_acquire_release, or for an atomic store to
have the memory_order_acquire or memory_order_acquire_release. Similarily, the
failure memory ordering for a compare-exchange cannot have a release component,
and must be weaker than the success case. In all of these cases, clang
currently emits either a relaxed operation (or the strongest valid ordering
that is weaker than the success ordering for cmpxchg) without emitting any

Here is a simple reproduction:
#include <atomic>
using namespace std;
atomic<int> x;
int f () {
x.store(42, memory_order_acquire);
return x.load(memory_order_release);
I would expect warnings on both the store and the load.

The relevant code appears to be the lines 256, 786, 792, 798 of
lib/CodeGen/CGAtomic.cpp, where the undefined behaviour is noted in the
comment, then a default choice is made.. all without any warning.

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20141006/88814139/attachment.html>

More information about the llvm-bugs mailing list