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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-12-09
                 CC|                            |msebor at gcc dot gnu.org
          Component|middle-end                  |c++
            Summary|spurious warning: null      |[5 regression] spurious
                   |argument where non-null     |warning: null argument
                   |required                    |where non-null required
     Ever confirmed|0                           |1

--- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> ---
Reproduced with yesterday's trunk.

I think the following simplification might make the problem clearer:

$ cat x.c && /build/gcc-trunk-svn/gcc/xgcc -B /build/gcc-trunk-svn/gcc -S -Wall
-o/dev/null -xc++ x.c
extern int len (const char*) __attribute__ ((__nonnull__ (1)));

int f (int x)
{
  return len ((x ? "x" : 0) ? (x ? "x" : 0) : "x");
}
x.c: In function ‘int f(int)’:
x.c:5:50: warning: null argument where non-null required (argument 1)
[-Wnonnul]
   return len ((x ? "x" : 0) ? (x ? "x" : 0) : "x");
                                                  ^

Interestingly, the problem seems specific to C++ and 6.0.  GCC (in C mode) or
5.1 in either C or C++ mode don't issue the warning.  I've changed the
Component to C++.

Reply via email to