https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108988

Andrew Pinski <pinskia at gcc dot gnu.org> 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 <pinskia at gcc dot gnu.org> ---
  /* Get the length of the string passed to fputs.  If the length
     can't be determined, punt.  */
  tree len = get_maxval_strlen (arg0, SRK_STRLEN);
  if (!len
      || TREE_CODE (len) != 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 = 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.

Reply via email to