HomePhabricator

This patch implements PR#22821.

Authored by rogfer01 on Aug 12 2016, 1:04 AM.

Description

This patch implements PR#22821.

Taking the address of a packed member is dangerous since the reduced
alignment of the pointee is lost. This can lead to memory alignment
faults in some architectures if the pointer value is dereferenced.

This change adds a new warning to clang emitted when taking the address
of a packed member. A packed member is either a field/data member
declared as attribute((packed)) or belonging to a struct/class
declared as such. The associated flag is -Waddress-of-packed-member.
Conversions (either implicit or via a valid casting) to pointer types
with lower or equal alignment requirements (e.g. void* or char*)
will silence the warning.

Differential Revision: https://reviews.llvm.org/D20561

llvm-svn: 278483

Details

Committed
rogfer01Aug 12 2016, 1:04 AM
Differential Revision
D20561: Warn when taking address of packed member
Parents
rG85c6b4481722: [ELF][MIPS] Support .MIPS.abiflags section
Branches
Unknown
Tags
Unknown