]> git.ipfire.org Git - thirdparty/gcc.git/commit
gimple-fold: Fix up fputs -> fwrite folding [PR108988]
authorJakub Jelinek <jakub@redhat.com>
Fri, 3 Mar 2023 10:13:40 +0000 (11:13 +0100)
committerJakub Jelinek <jakub@redhat.com>
Fri, 3 Mar 2023 10:19:37 +0000 (11:19 +0100)
commitdbeccab7a1f5dcc1876c854f17816047ba1ef137
treed2550d5f0cf276ae94a05c547c86b6bbf9c41d4a
parenta5c543910a1679ba3c9b78e3b362a16a150e2bf7
gimple-fold: Fix up fputs -> fwrite folding [PR108988]

gimple_fold_builtin_fputs when folding fputs into fwrite emits the third
argument (INTEGER_CST) with incorrect type - get_maxval_strlen or c_strlen
return ssizetype, while fwrite argument is size_type_node.
The following patch fixes that, I've skimmed through the rest of
gimple-fold.cc and in all other places get_maxval_strlen/c_strlen result
was fold_converted to size_type_node already (or GIMPLE cast stmt has been
emitted directly etc.).

2023-03-03  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/108988
* gimple-fold.cc (gimple_fold_builtin_fputs): Fold len to
size_type_node before passing it as argument to fwrite.  Formatting
fixes.
gcc/gimple-fold.cc