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

Roger Ferrer Ibanez via cfe-commits cfe-commits at lists.llvm.org
Fri May 27 02:07:17 PDT 2016


rogfer01 added a comment.

Forget my wrong comment about packed fields that might actually be aligned. It does not make sense.

Regarding the way to selectively disable this, there is little syntax available at this point that we can leverage, so I propose to use parentheses as a way to disable the warning, e.g. `&a.b` may warn but `&(a.b)` will never warn. This may not be ideal but is in practice not that far from the classical `( (x = b) )` idiom used to silence the assignment-vs-equality warning.

Closer examination of Firefox code shows that `memcpy`/`memcmp` are used with packed members in the networking code. Being able to disable those safe uses by means of parentheses seems sensible to me.

I will upload a new patch with this change.


http://reviews.llvm.org/D20561





More information about the cfe-commits mailing list