r278483 - This patch implements PR#22821.
Roger Ferrer Ibanez via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 3 00:10:08 PDT 2016
Hi Joerg,
thanks for your comments. I agree that these false positives are annoying.
I submitted a while ago a patch to address those false positives in https://reviews.llvm.org/D23657 but it is pending approval.
Kind regards,
Roger
> -----Original Message-----
> From: Joerg Sonnenberger [mailto:joerg at bec.de]
> Sent: 02 October 2016 07:24
> To: cfe-commits at lists.llvm.org
> Cc: Roger Ferrer Ibanez
> Subject: Re: r278483 - This patch implements PR#22821.
>
> On Sat, Oct 01, 2016 at 11:28:39PM +0200, Joerg Sonnenberger via cfe-
> commits wrote:
> > 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.
>
> Looking more at it, I request this warning to be disabled by default. In
> the current form it is useless and just makes it impossible to use
> packed structures at all. Before reenabling, it should handling:
> (1) Assignment to pointer with reduced alignment
> (2) Casts to pointer with reduced alignment
> (3) Use as function argument with implicit cast like (2).
>
> at the very least to cover normal use of packed member pointers.
>
> Joerg
More information about the cfe-commits
mailing list