<html>
    <head>
      <base href="https://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 --- - member alignment ignored when generating atomic load"
   href="https://llvm.org/bugs/show_bug.cgi?id=24875">24875</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>member alignment ignored when generating atomic load
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.7
          </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>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Backend: X86
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>davmac@davmac.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>LLVM 3.7, x86_64-pc-linux-gnu. The following program fails to link (using
libstdc++ from GCC 5.2.0):

--- begin ---
constexpr int memory_order_seq_cst = 5;

struct /* alignas(8) */ Term
{
    int a;
    int b;
};

class Atomic
{
    alignas(8) Term mm;

    public:

    Term load()
    {
        Term tmp;
        __atomic_load(&mm, &tmp, memory_order_seq_cst);
        return tmp;
    }
};

int main(int argc, char **argv)
{
    Atomic a;
    a.load();
    return 0;
}
--- end ---

Error at link is:
$ clang++ -std=c++11  clangatomic.cc 
/tmp/clangatomic-3242b4.o: In function `Atomic::load()':
clangatomic.cc:(.text._ZN6Atomic4loadEv[_ZN6Atomic4loadEv]+0x16): undefined
reference to `__atomic_load_8'
clang-3.7: error: linker command failed with exit code 1 (use -v to see
invocation)



If the 'alignas(8)' for struct Term is uncommented, the code compiles and links
ok. IIUC this shouldn't be required because there is an alignas(...) on the
'mm' member.

This may be related to: <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED INVALID - undefined reference to `__atomic_load_8', when it comes to 64-bit atomic load."
   href="show_bug.cgi?id=23262">https://llvm.org/bugs/show_bug.cgi?id=23262</a>
(but that is marked INVALID due to a bug in libstdc++. The example above
however does not use libstdc++).

This problem prevents using clang++ + libstdc++ with atomic operations.</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>