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

            Bug ID: 87424
           Summary: inlining context absent from missing nul warnings
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

The "missing terminating nul" warning newly issued by GCC 9 is missing inlining
context, making it difficult to determine which strlen call is the cause of the
problem.

$ cat d.c && gcc -O2 -S -Wall -fdump-tree-optimized=/dev/stdout d.c
static inline int f (const char *s)
{
  return __builtin_strlen (s);   // absent from diagnostic output
}

const char a[3] = { '1', '2', '3' };

int g (void)
{
  return f (a);
}
d.c: In function ‘g’:
d.c:10:13: warning: ‘strlen’ argument missing terminating nul
[-Wstringop-overflow=]
10 |   return f (a);
   |             ^
d.c:6:12: note: referenced argument declared here
6 | const char a[3] = { '1', '2', '3' };
  |            ^

;; Function g (g, funcdef_no=1, decl_uid=1910, cgraph_uid=2, symbol_order=2)

g ()
{
  long unsigned int _2;
  int _3;

  <bb 2> [local count: 1073741824]:
  _2 = __builtin_strlen (&a);
  _3 = (int) _2;
  return _3;

}

Reply via email to