https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63989
Bug ID: 63989
Summary: tree-ssa-strlen.c doesn't handle constant pointer plus
and array refs if constant offset is smaller than
known constant string length
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: jakub at gcc dot gnu.org
CC: dimhen at gmail dot com, jakub at gcc dot gnu.org,
nheghathivhistha at gmail dot com, rguenth at gcc dot
gnu.org,
trippels at gcc dot gnu.org
Depends on: 61773
Blocks: 63787
+++ This bug was initially created as a clone of Bug #61773 +++
char *foo (void)
{
char *p = __builtin_malloc (64);
char *q = __builtin_malloc (64);
__builtin_strcat (q, "abcde");
__builtin_strcat (p, "ab");
p[1] = q[3];
__builtin_strcat (p, q);
return q;
}
gives
> ../../obj2/gcc/cc1 -quiet -O2 t.c
t.c: In function ‘foo’:
t.c:1:7: internal compiler error: in get_string_length, at
tree-ssa-strlen.c:417
char *foo (void)
^
0x876c3d2 get_string_length
/space/rguenther/tramp3d/trunk/gcc/tree-ssa-strlen.c:417
0x8772b02 get_string_length
/space/rguenther/tramp3d/trunk/gcc/tree.h:2731
0x8772b02 handle_builtin_strlen
/space/rguenther/tramp3d/trunk/gcc/tree-ssa-strlen.c:899
(gdb) up
#1 0x0876c3d3 in get_string_length (si=0x3c)
at /space/rguenther/tramp3d/trunk/gcc/tree-ssa-strlen.c:417
417 gcc_assert (builtin_decl_implicit_p (BUILT_IN_STPCPY));
while trying to write a testcase that shows that handle_char_store should
handle a character copy from a known non-zero value. Well, while really
trying to incrementally teach handle_char_store to handle arbitrary
stores.