Commit bc626ae5 authored by Sylvestre Ledru's avatar Sylvestre Ledru
Browse files

Document -Wtautological-pointer-compare & -Wtautological-undefined-compare with example

llvm-svn: 215651
parent 4de5839c
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
@@ -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 <stddef.h>
    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 <stddef.h>
    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