[llvm-bugs] [Bug 38871] New: std::atomic not always atomic when compiling with GCC
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Sep 7 13:32:28 PDT 2018
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: unassignedclangbugs at nondot.org
Reporter: richard-llvm at metafoo.co.uk
CC: llvm-bugs at lists.llvm.org, mclow.lists at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180907/95d0886e/attachment.html>
More information about the llvm-bugs
mailing list