From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9B6C93858CDA; Fri, 14 Apr 2023 05:48:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9B6C93858CDA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1681451304; bh=4w58njbLZDiUcLRpyl/ucvxw4AGJ0Mmj7UHQLJmcaAc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=SYR4jxrJ6AhJnCrykEL5s9cAVLLqhY2pjs+l7wwjNASes9zEPNUo6N2Zq8CLgA44W CVt8V1OUPeEsUW4ce+7yjnNIuSzImsCtyAk4bELsmLKB2VWha3iBDY4sNLLk98XVO3 gAeahg0eFU2vNOM4pKPWoWf3/xQCT8HQ1YK27C8s= From: "ishikawa at yk dot rim.or.jp" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/94021] -Wformat-truncation false positive due to excessive integer range Date: Fri, 14 Apr 2023 05:48:23 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 9.2.1 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: ishikawa at yk dot rim.or.jp 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: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94021 --- Comment #10 from ishikawa,chiaki --- It would be great if the problem is fixed in later versions. I observe the error with gcc-12 on my computer yet. *BUT* compiling with -O instead of -O2 succeeds !? gcc-12 version. gcc-12 (Debian 12.2.0-14) 12.2.0 Copyright (C) 2022 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. No error with -O !? ishikawa@ip030:/NREF-COMM-CENTRAL/mozilla$ gcc-12 -c -O -Wall /tmp/pr94021.c Error with -O2 as before. ishikawa@ip030:/NREF-COMM-CENTRAL/mozilla$ gcc-12 -c -O2 -Wall /tmp/pr94021= .c /tmp/pr94021.c: In function =E2=80=98format_utc_offset=E2=80=99: /tmp/pr94021.c:14:45: warning: =E2=80=98%02i=E2=80=99 directive output may = be truncated writing 2 bytes into a region of size between 1 and 5 [-Wformat-truncation=3D] 14 | __builtin_snprintf (a, sizeof a, "%s%02i%02i", "+", h, m); | ^~~~ /tmp/pr94021.c:14:38: note: directive argument in the range [0, 59] 14 | __builtin_snprintf (a, sizeof a, "%s%02i%02i", "+", h, m); | ^~~~~~~~~~~~ /tmp/pr94021.c:14:5: note: =E2=80=98__builtin_snprintf=E2=80=99 output betw= een 6 and 10 bytes into a destination of size 8 14 | __builtin_snprintf (a, sizeof a, "%s%02i%02i", "+", h, m); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ishikawa@ip030:/NREF-COMM-CENTRAL/mozilla$=