<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - No warnings for invalid memory orderings for atomic accesses"
   href="http://llvm.org/bugs/show_bug.cgi?id=21179">21179</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>No warnings for invalid memory orderings for atomic accesses
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++11
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>morisset@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, jfb@google.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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
warning.

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.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>