From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 544083858D35; Wed, 21 Jun 2023 04:28:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 544083858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687321698; bh=rUVH1bgEH0m4gHUkjcuZVgBxkik3k/BnlfSfb3/BByk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=oWnVxcPNaQo5AZJFX0x6JZYILP6t7OXHkqoXHmG7pC2S6sw5UFSlZyckQaayuT4gj q4Ip8rKpgmBLXIl2ZCGWLcGZ2yfESmR85aYKxRKP8HBXjBr57pWeS7MeH0tD9usc93 9CgXhEeG8lU0fRNnekmeTPfwO7jHNcough38L4kc= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/80776] -Wformat-overflow false positive for %d on integer bounded by __builtin_unreachable Date: Wed, 21 Jun 2023 04:28:17 +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: 7.1.0 X-Bugzilla-Keywords: diagnostic, missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: target_milestone 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=3D80776 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |13.0 --- Comment #8 from Andrew Pinski --- (In reply to Martin Sebor from comment #7) > Reconfirming that test case in comment #2 still triggers the warning in G= CC > 10. The dump shows that the warning thinks the fifth directive (%02d) > generates between 2 and 10 bytes of output. The symptoms feel similar to > pr94021 but I haven't looked into whether they underlying root causes are > related. That testcase looks to be fixed in GCC 13: /app/example.cpp:13: __builtin_sprintf: objsize =3D 15, fmtstr =3D "%04d%02d%02d%02d%02d%02d" Directive 1 at offset 0: "%04d" Result: 4, 4, 4, 4 (4, 4, 4, 4) Directive 2 at offset 4: "%02d" Result: 2, 2, 2, 2 (6, 6, 6, 6) Directive 3 at offset 8: "%02d" Result: 2, 2, 2, 2 (8, 8, 8, 8) Directive 4 at offset 12: "%02d" Result: 2, 2, 2, 2 (10, 10, 10, 10) Directive 5 at offset 16: "%02d" Result: 2, 2, 2, 2 (12, 12, 12, 12) Directive 6 at offset 20: "%02d" Result: 2, 2, 2, 2 (14, 14, 14, 14) Directive 7 at offset 24: "", length =3D 1 Substituting 14 for return value. GCC 13: # RANGE [irange] int [-999, 9999] intD.6 a_14(D) =3D aD.2739; # RANGE [irange] int [1, 12] NONZERO 0xf intD.6 b_15(D) =3D bD.2740; # RANGE [irange] int [1, 31] NONZERO 0x1f intD.6 c_16(D) =3D cD.2741; # RANGE [irange] int [0, 23] NONZERO 0x1f intD.6 d_17(D) =3D dD.2742; # RANGE [irange] int [0, 59] NONZERO 0x3f intD.6 e_18(D) =3D eD.2743; # RANGE [irange] int [0, 60] NONZERO 0x3f intD.6 f_19(D) =3D fD.2744; GCC 12: # RANGE [-999, 9999] intD.6 a_14(D) =3D aD.1979; # RANGE [1, 12] NONZERO 15 intD.6 b_15(D) =3D bD.1980; # RANGE [1, 31] NONZERO 31 intD.6 c_16(D) =3D cD.1981; # RANGE [0, 23] NONZERO 31 intD.6 d_17(D) =3D dD.1982; # RANGE [0, 2147483647] NONZERO 2147483647 intD.6 e_18(D) =3D eD.1983; # RANGE [0, 2147483647] NONZERO 2147483647 intD.6 f_19(D) =3D fD.1984; So yes this has been fixed for GCC 13.=