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 middle-end/68767] New: spurious warning: null argument where non-null required


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

            Bug ID: 68767
           Summary: spurious warning: null argument where non-null
                    required
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: amylaar at gcc dot gnu.org
  Target Milestone: ---

This test, compiled with g++ -c -Werror -Wall:

// { dg-do compile }
// { dg-options "-Werror -Wall" }

extern int len (const char *__s)
     throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));

extern int num;

int
f (void)
{
  int i;

  i = len ((((num != 2) ? "lstr" : num == 1 ? "str" : 0) ? ((num != 2) ? "lstr"
: num == 1 ? "str" : 0) : "lstr" ));
  return i;
}

gets the spurious warning:
tmp.C:14:115: error: null argument where non-null required (argument 1)
[-Werror=nonnull]
 m == 1 ? "str" : 0) ? ((num != 2) ? "lstr" : num == 1 ? "str" : 0) : "lstr"
));
                                                                              ^
Ironically, this is condensed down from c-common.c complaining about itself
when building gcc for a target with a variable BITS_PER_UNIT, which also uses
newlib-stdint.h .

Originally observed with g++ (GCC) 5.1.1 20150618 (Red Hat 5.1.1-4), but also
reproduced with g++ (GCC) 6.0.0 20151207 (experimental) .

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