HomePhabricator

Warn when taking address of a packed member

Description

Warn when taking address of a packed member

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

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

Details

Committed
rogfer01Jun 13 2016, 8:41 AM
Differential Revision
D20561: Warn when taking address of packed member
Branches
Unknown
Tags
Unknown
Reverted By
rC272653: Reverting "Warn when taking address of a packed member"