summaryrefslogtreecommitdiff
path: root/absl/base
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2021-09-07 06:10:15 -0700
committerGravatar dinord <dinor@google.com>2021-09-07 16:36:10 +0000
commit8c800bb08d353c73d7dd68538388cf3bd2bcc6d0 (patch)
treea74888437fca9f8dc654a28f800b971d2efbe6f5 /absl/base
parent6039dd95bb62e6072731929279e917c7be39369f (diff)
Export of internal Abseil changes
-- 6eac0cc7bca997ee95afd4ec485077ae8fd99333 by Abseil Team <absl-team@google.com>: Add comment not to use `ABSL_ATTRIBUTE_PACKED` with `std::atomic`. PiperOrigin-RevId: 395231460 GitOrigin-RevId: 6eac0cc7bca997ee95afd4ec485077ae8fd99333 Change-Id: Ib4e83bed0f313724b309b6278e9e24a6e5fe9b2c
Diffstat (limited to 'absl/base')
-rw-r--r--absl/base/attributes.h20
1 files changed, 13 insertions, 7 deletions
diff --git a/absl/base/attributes.h b/absl/base/attributes.h
index 52139556..2665d8f3 100644
--- a/absl/base/attributes.h
+++ b/absl/base/attributes.h
@@ -548,13 +548,19 @@
// ABSL_ATTRIBUTE_PACKED
//
// Instructs the compiler not to use natural alignment for a tagged data
-// structure, but instead to reduce its alignment to 1. This attribute can
-// either be applied to members of a structure or to a structure in its
-// entirety. Applying this attribute (judiciously) to a structure in its
-// entirety to optimize the memory footprint of very commonly-used structs is
-// fine. Do not apply this attribute to a structure in its entirety if the
-// purpose is to control the offsets of the members in the structure. Instead,
-// apply this attribute only to structure members that need it.
+// structure, but instead to reduce its alignment to 1.
+//
+// Therefore, DO NOT APPLY THIS ATTRIBUTE TO STRUCTS CONTAINING ATOMICS. Doing
+// so can cause atomic variables to be mis-aligned and silently violate
+// atomicity on x86.
+//
+// This attribute can either be applied to members of a structure or to a
+// structure in its entirety. Applying this attribute (judiciously) to a
+// structure in its entirety to optimize the memory footprint of very
+// commonly-used structs is fine. Do not apply this attribute to a structure in
+// its entirety if the purpose is to control the offsets of the members in the
+// structure. Instead, apply this attribute only to structure members that need
+// it.
//
// When applying ABSL_ATTRIBUTE_PACKED only to specific structure members the
// natural alignment of structure members not annotated is preserved. Aligned