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

            Bug ID: 38871
           Summary: std::atomic not always atomic when compiling with GCC
           Product: libc++
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangb...@nondot.org
          Reporter: richard-l...@metafoo.co.uk
                CC: llvm-bugs@lists.llvm.org, mclow.li...@gmail.com

Compiling this with GCC:

#include <atomic>
struct X { char c[4]; };
std::atomic<X> x;

... results in a call to __atomic_load to load the X object. However, due to
gcc.gnu.org/PR87237, that builtin is not actually atomic in this case.

libstdc++ works around this by increasing the alignment of atomic<X> to
sizeof(X) if sizeof(X) is a power of 2 not greater than 16, so that's
presumably the set of cases where the GCC bug occurs. libc++ should probably do
the same.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to