From: Sylvestre Ledru Date: Thu, 14 Aug 2014 16:09:45 +0000 (+0000) Subject: Document -Wtautological-pointer-compare & -Wtautological-undefined-compare with example X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cc2ffe2aaba037e5746140432374609a25338c60;p=clang Document -Wtautological-pointer-compare & -Wtautological-undefined-compare with example git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_35@215651 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/docs/ReleaseNotes.rst b/docs/ReleaseNotes.rst index c7c701be99..995f906534 100644 --- a/docs/ReleaseNotes.rst +++ b/docs/ReleaseNotes.rst @@ -70,6 +70,38 @@ about them. The improvements since the 3.4 release include: - New warning `-Wabsolute-value`: Clang warns about incorrect or useless usage of the absolute functions (`abs`, `fabsf`, etc). +- New warning `-Wtautological-pointer-compare`: + + .. code-block:: c++ + + #include + void foo() { + int arr[5]; + int x; + // warn on these conditionals + if (foo); + if (arr); + if (&x); + if (foo == NULL); + if (arr == NULL); + if (&x == NULL); + } + + returns + `warning: comparison of address of 'x' equal to a null pointer is always false [-Wtautological-pointer-compare]` + +- New warning `-Wtautological-undefined-compare`: + + .. code-block:: c++ + + #include + void f(int &x) { + if (&x == nullptr) { } + } + + returns + `warning: reference cannot be bound to dereferenced null pointer in well-defined C++ code; comparison may be assumed to always evaluate to false [-Wtautological-undefined-compare]` + - ... New Compiler Flags