https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85119
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |msebor at gcc dot gnu.org
Resolution|--- |DUPLICATE
--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
It's not __builtin_expect that suppresses the warning but rather the
parentheses around the expression (see below). The problem is the subject of
bug 74762.
$ cat u.C && gcc -S -Wall -Wextra u.C
struct S
{
void f ();
void g ();
};
void S::g ()
{
if (!this) f (); // -Wnonnull-compare (good)
if ((!this)) f (); // missing -Wnonnull-compare
}
u.C: In member function ‘void S::g()’:
u.C:10:3: warning: nonnull argument ‘this’ compared to NULL [-Wnonnull-compare]
if (!this) f (); // -Wnonnull-compare (good)
^~
*** This bug has been marked as a duplicate of bug 74762 ***