This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/77298] -Wnonnull-compare only emitted for code which is invoked


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77298

--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
I should add that Clang issues the warning for all three functions:

$ /build/llvm-trunk/bin/clang -S -Wall -Wextra -Wpedantic z.C
z.C:2:21: warning: 'this' pointer cannot be null in well-defined C++ code;
      pointer may be assumed to always convert to true
      [-Wundefined-bool-conversion]
  int f () { return this ? 1 : 0; }
                    ^~~~ ~
z.C:6:21: warning: 'this' pointer cannot be null in well-defined C++ code;
      pointer may be assumed to always convert to true
      [-Wundefined-bool-conversion]
  int f () { return this ? 1 : 0; }
                    ^~~~ ~
z.C:13:22: warning: 'this' pointer cannot be null in well-defined C++ code;
      pointer may be assumed to always convert to true
      [-Wundefined-bool-conversion]
int C::f () { return this ? 1 : 0; }
                     ^~~~ ~
3 warnings generated.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]