public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/98483] New: missing -Warray-bounds for out of bounds accesses in system headers
@ 2020-12-30 22:01 msebor at gcc dot gnu.org
0 siblings, 0 replies; only message in thread
From: msebor at gcc dot gnu.org @ 2020-12-30 22:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98483
Bug ID: 98483
Summary: missing -Warray-bounds for out of bounds accesses in
system headers
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
GCC warns for out-of-bounds accesses by inlined functions but not when they are
defined in system headers, even if the function is inlined into (and the
accessed object defined in) an ordinary, non-systen function. This is
especially bad for C++ system libraries that are full of inline code.
$ cat b.c && gcc -O2 -S -Wall -fdump-tree-optimized=/dev/stdout b.c
# 1 "a.h" 1 3 4
# 2 "a.h" 3 4
static inline void f (int *p)
{
*p = 0;
}
# 1 "b.c" 1
static inline void g (int *p)
{
*p = 1;
}
int i[1];
void ff (void)
{
f (i + 1); // missing warning
}
void gg (void)
{
g (i + 1); // warning (good)
}
;; Function ff (ff, funcdef_no=2, decl_uid=1950, cgraph_uid=3, symbol_order=3)
void ff ()
{
<bb 2> [local count: 1073741824]:
MEM[(int *)&i + 4B] = 0;
return;
}
In file included from a.h:7,
from b.c:1:
b.c: In function ‘gg’:
b.c:4:6: warning: array subscript 1 is outside array bounds of ‘int[1]’
[-Warray-bounds]
4 | {
| ^
b.c:7:5: note: while referencing ‘i’
7 |
| ^
;; Function gg (gg, funcdef_no=3, decl_uid=1953, cgraph_uid=4, symbol_order=4)
void gg ()
{
<bb 2> [local count: 1073741824]:
MEM[(int *)&i + 4B] = 1;
return;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-12-30 22:01 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-30 22:01 [Bug middle-end/98483] New: missing -Warray-bounds for out of bounds accesses in system headers msebor at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).