[PATCH] D38718: Patch to Bugzilla 20951

Daniel Marjamäki via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 10 04:04:54 PDT 2017

danielmarjamaki added a reviewer: danielmarjamaki.
danielmarjamaki added a comment.

I think a test for -Wtautological-pointer-compare should be added that shows that the bug is fixed.

Comment at: test/Sema/conditional-expr.c:84
+  //char x;
+  return (((x != ((void *) 0)) ? (*x = ((char) 1)) : (void) ((void *) 0)), (unsigned long) ((void *) 0)); // expected-warning {{C99 forbids conditional expressions with only one void side}}
lebedev.ri wrote:
> Please don't just remove previous tests.
> E.g. does the old test no longer warns?
no test is removed. The expected-warning is unchanged.

the problem with the test was that this comparison is always true:
    (&x) != ((void *)0)
the address of x is never 0!

Fixing https://bugs.llvm.org/show_bug.cgi?id=20951 means Clang will warn:
warning: comparison of address of 'x' not equal to a null pointer is always true [-Wtautological-pointer-compare]

We changed the test so the -Wtautological-pointer-compare is not reported... but the original warning is still reported.


More information about the cfe-commits mailing list