https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86528
Bernd Edlinger <bernd.edlinger at hotmail dot de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bernd.edlinger at hotmail dot de --- Comment #3 from Bernd Edlinger <bernd.edlinger at hotmail dot de> --- I can reproduce with the following test case: $ cat t.c #include <stdlib.h> #include <stdio.h> #include <string.h> void test(char *data, size_t len) { char *dir; static char const appended[] = "/./"; char *buf = alloca (len + sizeof appended); memcpy (buf, data, len); strcpy (buf + len, &appended[data[len - 1] == '/']); dir = buf; printf("%s\n", dir); } int main(int argc, char **argv) { if(argc > 1 && argv[1][0]) test(argv[1], strlen(argv[1])); return 0; } $ gcc -S -O1 -fdump-tree-all-all t.c t.c.028t.ccp1 looks okay: # VUSE <.MEM_14> _4 = *_3; _5 = _4 == 47; _6 = (intD.6) _5; _7 = &appended.3294D.3294[_6]; _8 = buf_12 + len_9(D); # .MEM_15 = VDEF <.MEM_14> # USE = anything # CLB = anything strcpyD.887 (_8, _7); t.c.029t.forwprop1 is wrong: # VUSE <.MEM_14> _4 = *_3; _5 = _4 == 47; _6 = (intD.6) _5; _7 = &appended.3294D.3294[_6]; _8 = buf_12 + len_9(D); _18 = (long unsigned intD.10) _6; _19 = _18 * 18446744073709551612; _20 = _19 + 4; # .MEM_15 = VDEF <.MEM_14> # USE = anything # CLB = anything memcpyD.864 (_8, _7, _20); Breakpoint 7, string_constant (arg=0x7ffff70a0dc8, ptr_offset=0x7fffffffc638) at ../../gcc-9-20180715/gcc/expr.c:11344 11344 if (tree eltsize = TYPE_SIZE_UNIT (TREE_TYPE (array))) here eltsize = 4, but it should probably be TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (array))) ???