Bug 87424 - inlining context absent from missing nul warnings
Summary: inlining context absent from missing nul warnings
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 9.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2018-09-24 20:07 UTC by Martin Sebor
Modified: 2018-09-24 20:13 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Sebor 2018-09-24 20:07:09 UTC
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;

}