[PATCH] PR12463 : Warnings about nonsensical comparisons are disabled if macro expansion is involved #2

Richard Smith richard at metafoo.co.uk
Sat Apr 12 18:17:28 PDT 2014


On Fri, Apr 4, 2014 at 3:54 AM, Lubos Lunak <l.lunak at centrum.cz> wrote:

>
>  This is a reduced version of the original patch for PR12463 that handles
> only
> string comparisons (I don't care about arrays enough to deal with the
> details
> and there the problem is unlikely to happen anyway, but the problem is more
> likely with strings if e.g. refactoring).


It seems a bit strange to treat arrays and string literals differently
(since string literals are basically just a weird way to write and name a
unique array). From your comments on the PR, I guess you're concerned about
false positives on this kind of case:

  #define ARRAY_COPY(x, y) do { if ((x) == (y)) { /* same array */ } else {
memcpy(&(x)[0], &(y)[0], min(sizeof(x), sizeof(y))); } } while (0)

... where it's intentional for x and y to be arrays. But for that code,
it'd be equally fine for y to be a string literal.

Do you have any numbers for true positives / false positives with this
diagnostic change?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140412/d84c627b/attachment.html>


More information about the cfe-commits mailing list