From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 561D4385B835; Sat, 18 Apr 2020 11:13:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 561D4385B835 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1587208419; bh=b9XCfmcMpJwr7gEg/wuMFhJL8uedu4wdl7Tp+d8d2hw=; h=From:To:Subject:Date:From; b=tbguaTku+LHJz7Ysl9fob8MbC8R5kV00vniqP6oSyvialDn0pocGDUifLmETErbTG d7qnzcNQGBrF+NgL14KbcBcWOI0/zV6f3fmt7pcFD37bryBs8djh60BTQNeM1g2zN4 9cHAmZaP9fnyeFuYa9zC06CY/1pwAecEbgsMwdKw= From: "doko at debian dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug other/94647] New: [10 Regression] wrong diagnostic with -Werror=format-security Date: Sat, 18 Apr 2020 11:13:39 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: other X-Bugzilla-Version: 10.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: doko at debian dot 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: Sat, 18 Apr 2020 11:13:39 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94647 Bug ID: 94647 Summary: [10 Regression] wrong diagnostic with -Werror=3Dformat-security Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: other Assignee: unassigned at gcc dot gnu.org Reporter: doko at debian dot org Target Milestone: --- [forwarded from https://bugs.debian.org/958062] seen with trunk 20200417, works with the gcc-9 branch. $ cat testcase.c /* Compile with gcc-10 -O2 -c testcase.c -Wall -Wformat -Werror=3Dformat-se= curity */ #include struct a { int pad; char string[512]; }; struct b { int pad; char string[256]; }; int f(struct a *d, struct b *s) { int l; /* No warning here, so GCC 10 assumes that d->string is properly * null terminated. */ l =3D strlen(d->string); /* Warning here, GCC 10 assumes that d->string is *not* properly * null terminated */ strncpy(d->string, s->string, sizeof(d->string)); return l; } $ gcc-10 -O2 -c testcase.c -Wall -Wformat -Werror=3Dformat-security In file included from /usr/include/string.h:495, from testcase.c:3: In function =E2=80=98strncpy=E2=80=99, inlined from =E2=80=98f=E2=80=99 at testcase.c:27:2: /usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: warning: =E2=80=98__builtin_strncpy=E2=80=99 offset [260, 511] from the object at = =E2=80=98s=E2=80=99 is out of the bounds of referenced subobject =E2=80=98string=E2=80=99 with type =E2=80=98= char[256]=E2=80=99 at offset 4 [-Warray-bounds] 106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~~~~ testcase.c: In function =E2=80=98f=E2=80=99: testcase.c:14:7: note: subobject =E2=80=98string=E2=80=99 declared here 14 | char string[256]; | ^~~~~~=