From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CB78A3857C49; Wed, 30 Dec 2020 22:29:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CB78A3857C49 From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/98484] New: missing -Wstringop-overflow on a multiply inlined calls from system header Date: Wed, 30 Dec 2020 22:29:08 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: msebor at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Dec 2020 22:29:08 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98484 Bug ID: 98484 Summary: missing -Wstringop-overflow on a multiply inlined calls from system header 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 11 diagnoses invalid accesses by built-in functions like memcpy made in inlined calls to functions defined in system headers, but apparently only f= or a single level of inlining. When the function that does the invalid access is itself called from another inline function it isn't diagnosed. (I noticed = this while looking into pr98465.) $ cat b.c && gcc -O2 -S -Wall -fdump-tree-optimized=3D/dev/stdout b.c # 1 "a.h" 1 3 4 # 2 "a.h" 3 4 static inline void f0 (void *p) { __builtin_memcpy (p, "12345678", 8); } static inline void f1 (void *p) { f0 (p); } # 1 "b.c" 1 static inline void f2 (void *p) { f0 (p); } extern char a[8]; void g0 (void) { f0 (a + 4); // missing warning } void g1 (void) { f1 (a + 4); // missing warning } void g2 (void) { f2 (a + 4); // missing warning } ;; Function g0 (g0, funcdef_no=3D3, decl_uid=3D1953, cgraph_uid=3D4, symbol= _order=3D3) void g0 () { [local count: 1073741824]: __builtin_memcpy (&MEM [(void *)&a + 4B], "12345678", 8); [tail call] return; } In file included from b.c:1: In function =E2=80=98f0=E2=80=99, inlined from =E2=80=98g0=E2=80=99 at b.c:11:3: a.h:4:3: warning: =E2=80=98__builtin_memcpy=E2=80=99 writing 8 bytes into a= region of size 4 overflows the destination [-Wstringop-overflow=3D] 4 |=20 | ^=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20 In file included from a.h:12, from b.c:1: a.h: In function =E2=80=98g0=E2=80=99: b.c:7:13: note: at offset 4 into destination object =E2=80=98a=E2=80=99 of = size 8 7 |=20 | ^ ;; Function g1 (g1, funcdef_no=3D7, decl_uid=3D1956, cgraph_uid=3D5, symbol= _order=3D4) void g1 () { [local count: 1073741824]: __builtin_memcpy (&MEM [(void *)&a + 4B], "12345678", 8); [tail call] return; } ;; Function g2 (g2, funcdef_no=3D9, decl_uid=3D1959, cgraph_uid=3D6, symbol= _order=3D5) void g2 () { [local count: 1073741824]: __builtin_memcpy (&MEM [(void *)&a + 4B], "12345678", 8); [tail call] return; }=