From bb04901d14f7749eb949092fd3dfcb6ca1958701 Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Tue, 18 Aug 2020 12:49:35 -0600 Subject: Fix PR tree-optimization/96670 - ICE on memchr with an empty initializer. gcc/ChangeLog: PR tree-optimization/96670 PR middle-end/78257 * gimple-fold.c (gimple_fold_builtin_memchr): Call byte_representation to get it, not string_constant. gcc/testsuite/ChangeLog: PR tree-optimization/96670 * gcc.dg/memchr-2.c: New test. * gcc.dg/memcmp-6.c: New test. --- gcc/gimple-fold.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/gimple-fold.c') diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index db56cb6..dcc1b56 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -2670,7 +2670,7 @@ gimple_fold_builtin_memchr (gimple_stmt_iterator *gsi) if (r == NULL) { tree mem_size, offset_node; - string_constant (arg1, &offset_node, &mem_size, NULL); + byte_representation (arg1, &offset_node, &mem_size, NULL); unsigned HOST_WIDE_INT offset = (offset_node == NULL_TREE) ? 0 : tree_to_uhwi (offset_node); /* MEM_SIZE is the size of the array the string literal -- cgit v1.1