[llvm-bugs] [Bug 24875] New: member alignment ignored when generating atomic load

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Sep 18 09:47:52 PDT 2015


https://llvm.org/bugs/show_bug.cgi?id=24875

            Bug ID: 24875
           Summary: member alignment ignored when generating atomic load
           Product: libraries
           Version: 3.7
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: davmac at davmac.org
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

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: https://llvm.org/bugs/show_bug.cgi?id=23262
(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.

-- 
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/20150918/e5fc0974/attachment-0001.html>


More information about the llvm-bugs mailing list