[PATCH] D20561: Warn when taking address of packed member

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 13 16:12:08 PDT 2016


On Mon, Jun 13, 2016 at 6:30 PM, Evgeniy Stepanov <eugenis at google.com> wrote:
> eugenis added a subscriber: eugenis.
> eugenis added a comment.
>
> In http://reviews.llvm.org/D20561#446031, @aaron.ballman wrote:
>
>> In http://reviews.llvm.org/D20561#445824, @rogfer01 wrote:
>>
>> > I think I wasn't clear with the purpose of the fix-it: there are a few cases where getting the address of an unaligned pointer is safe (i.e. false positives).
>> >
>> > For instance, when I checked Firefox and Chromium there are cases where getting the address of an unaligned pointer is fine. For the particular case of these two browsers, they both use a library (usrsctp) that represents protocol data as packed structs. That library passes addresses of packed fields to `memcpy` and `memmove` which is OK.
>>
>>
>> I think this is a false-positive that should be fixed.
>
>
> This patch was committed without fixing the false positive case, why?

Can you give some more code context, like perhaps a test case we can
add to the suite? I believe the current behavior should be essentially
false-positive-free because it only triggers the diagnostic when the
alignments actually differ, so if there are other false-positives, I
agree that we should determine a disposition for them.

> Could this warning be excluded from -Wall?

Would you like the warning to be excluded from -Wall even if the
false-positive is fixed?

~Aaron


More information about the cfe-commits mailing list