aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple-fold.c
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2020-11-25 11:00:10 -0700
committerMartin Sebor <msebor@redhat.com>2020-11-25 11:02:11 -0700
commitaec2d6849160f92cd45f97d6c3bdd8808ab01fa6 (patch)
treef1d8ab6cc86952b36119f027b0b9342bd70c5554 /gcc/gimple-fold.c
parent9d908b7fc475b351622fa5630d4874068c789d70 (diff)
downloadgcc-aec2d6849160f92cd45f97d6c3bdd8808ab01fa6.zip
gcc-aec2d6849160f92cd45f97d6c3bdd8808ab01fa6.tar.gz
gcc-aec2d6849160f92cd45f97d6c3bdd8808ab01fa6.tar.bz2
PR middle-end/97956 - ICE due to type mismatch in pointer_plus_expr during memchr folding
gcc/ChangeLog: PR middle-end/97956 * gimple-fold.c (gimple_fold_builtin_memchr): Use sizetype for pointer offsets. gcc/testsuite/ChangeLog: PR middle-end/97956 * gcc.dg/memchr-3.c: New test.
Diffstat (limited to 'gcc/gimple-fold.c')
-rw-r--r--gcc/gimple-fold.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index 40fc7e4..58b6ea4 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -2689,7 +2689,7 @@ gimple_fold_builtin_memchr (gimple_stmt_iterator *gsi)
gimple_seq stmts = NULL;
if (lhs != NULL_TREE)
{
- tree offset_cst = build_int_cst (TREE_TYPE (len), offset);
+ tree offset_cst = build_int_cst (sizetype, offset);
gassign *stmt = gimple_build_assign (lhs, POINTER_PLUS_EXPR,
arg1, offset_cst);
gimple_seq_add_stmt_without_update (&stmts, stmt);