From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AEB083858C83; Wed, 1 Mar 2023 22:20:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AEB083858C83 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677709255; bh=3d3rS7dbwXH0lSPcEgz3tYVfNCoGyfaVeBJuNNpVoLw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=U8xo81UXt85qgiNvcp8jimwBoyArCeC+yzXx1d+9rs81jgExtgxGE9lVP1qX9haBS 27UWLk+lxhsBK9WOXbEf3vzlljrwrXHTsfzKh/EVQYLd0SVethPwLrMEnH3aLIEd2J 97LVQT1v97f5VduOG3ZGBaKnpBHcIDuyeMxrWp6s= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/108988] gimple_fold_builtin_fputs doesn't preserve gimple_builtin_call_types_compatible_p Date: Wed, 01 Mar 2023 22:20:55 +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: 13.0 X-Bugzilla-Keywords: internal-improvement X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia 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: keywords bug_status everconfirmed cf_reconfirmed_on component 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=3D108988 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |internal-improvement Status|UNCONFIRMED |NEW Ever confirmed|0 |1 Last reconfirmed| |2023-03-01 Component|middle-end |tree-optimization --- Comment #2 from Andrew Pinski --- /* Get the length of the string passed to fputs. If the length can't be determined, punt. */ tree len =3D get_maxval_strlen (arg0, SRK_STRLEN); if (!len || TREE_CODE (len) !=3D INTEGER_CST) return false; And before we had a call to c_strlen. In both cases, they both always returned a size in ssizetype. As far as I can tell this has been broken since the merge of the tree-ssa branch into the trunk. I have not done a "git blame" on the tree-ssa branch= to see which revision introduced this without a cast. Confirmed. gimple *repl =3D gimple_build_call (fn_fwrite, 4, arg0, size_one_node, len, arg1); replace_call_with_call_and_fold (gsi, repl); Basically you need to add a fold_convert of len to size_type_node and do a temporary if needed.=