From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1D42D385841B; Wed, 19 Jan 2022 17:35:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1D42D385841B From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/89161] Bogus -Wformat-overflow warning with value range known Date: Wed, 19 Jan 2022 17:35:05 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 7.4.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: msebor at gcc dot gnu.org X-Bugzilla-Status: NEW 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: cf_known_to_fail cf_reconfirmed_on Message-ID: In-Reply-To: References: 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, 19 Jan 2022 17:35:05 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D89161 Martin Sebor changed: What |Removed |Added ---------------------------------------------------------------------------- Known to fail|10.0 |10.3.0, 11.2.0, 12.0 Last reconfirmed|2020-05-01 00:00:00 |2022-1-19 --- Comment #5 from Martin Sebor --- GCC 12 or 11 don't warn on the test case in comment #3 but reconfirming the warning for the test case in comment #0 with GCC 12: $ gcc -O2 -S -Wall -fdump-tree-strlen=3D/dev/stdout pr89161.c=20 ;; Function main (main, funcdef_no=3D12, decl_uid=3D2421, cgraph_uid=3D13, symbol_order=3D13) (executed once) ... pr89161.c:7: sprintf: objsize =3D 3, fmtstr =3D ".%1u" Directive 1 at offset 0: ".", length =3D 1 Result: 1, 1, 1, 1 (1, 1, 1, 1) Directive 2 at offset 1: "%1u" pr89161.c: In function =E2=80=98main=E2=80=99: pr89161.c:7:24: warning: =E2=80=98%1u=E2=80=99 directive writing between 1 = and 6 bytes into a region of size 2 [-Wformat-overflow=3D] 7 | sprintf(buf, ".%1u", (10 * a[0]) / a[1]); | ^~~ In function =E2=80=98print=E2=80=99, inlined from =E2=80=98main=E2=80=99 at pr89161.c:17:5: pr89161.c:7:22: note: directive argument in the range [0, 327670] 7 | sprintf(buf, ".%1u", (10 * a[0]) / a[1]); | ^~~~~~ Result: 1, 6, 6, 6 (2, 7, 7, 7) Directive 3 at offset 4: "", length =3D 1 pr89161.c:7:9: note: =E2=80=98sprintf=E2=80=99 output between 3 and 8 bytes= into a destination of size 3 7 | sprintf(buf, ".%1u", (10 * a[0]) / a[1]); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~=