https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88775

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
"hello" string literal surely can be followed by anything else, but don't we
consider it UB?
int
foo (void)
{
  int a = 0;
  for (int i = 0; i < 32; i++)
    a += "hello"[i];
  return a;
}
warning: iteration 6 invokes undefined behavior
[-Waggressive-loop-optimizations]
     a += "hello"[i];
          ~~~~~~~^~~
So,
__builtin_memcpy (xyz, &MEM[(void *)"hello" + 5B], 5);
is the same kind of UB.
Note, I don't see any:
__builtin_memcpy ("hello", ..., 5);
in my IL, that would be another UB unless string literals are writable.

Reply via email to