r278483 - This patch implements PR#22821.

Joerg Sonnenberger via cfe-commits cfe-commits at lists.llvm.org
Sat Oct 1 14:28:39 PDT 2016


On Fri, Aug 12, 2016 at 08:04:13AM -0000, Roger Ferrer Ibanez via cfe-commits wrote:
> Author: rogfer01
> Date: Fri Aug 12 03:04:13 2016
> New Revision: 278483
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=278483&view=rev
> Log:
> 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 triggers on LVM in a rather obvious false positive:

    (uintptr_t) &lh->offset_xl

Given that one correct use case is to take the address and cast it to
void * (or uintptr_t) for use without caring about alignment, the
warning clearly needs to be refined.

I'm also missing a test case in this commit. Most importantly, it should
test, whether it correctly handles the case of packed+align where
align > alignof(field).

Joerg


More information about the cfe-commits mailing list