Skip to content

Commit 872cb63

Browse files
jmrcopybara-github
authored andcommitted
base: Discourage use of ABSL_ATTRIBUTE_PACKED
Taking the address of or binding a reference to any unaligned member is UB. PiperOrigin-RevId: 834128867 Change-Id: I408f25496517cf18784c58dbe796d32e3c856553
1 parent a5e3599 commit 872cb63

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

absl/base/attributes.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,11 @@
580580
// Instructs the compiler not to use natural alignment for a tagged data
581581
// structure, but instead to reduce its alignment to 1.
582582
//
583-
// Therefore, DO NOT APPLY THIS ATTRIBUTE TO STRUCTS CONTAINING ATOMICS. Doing
583+
// Use of this attribute is HIGHLY DISCOURAGED. Taking the address of or
584+
// binding a reference to any unaligned member is UB, and it is very easy to
585+
// do so unintentionally when passing such members as function arguments.
586+
//
587+
// DO NOT APPLY THIS ATTRIBUTE TO STRUCTS CONTAINING ATOMICS. Doing
584588
// so can cause atomic variables to be mis-aligned and silently violate
585589
// atomicity on x86.
586590
//

0 commit comments

Comments
 (0)