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

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I don't see any bug actually.  You are just saying that the str1 variable is
__flash, during optimization (already in C FE) it optimizes str1[i] into
"0123456789"[i] and that is the string literal that is mergeable, string
literals unlike variables don't really have non-default address spaces.
If you want to prevent that, either make the var const volatile, or use some
optimization barrier, like:
  static const __flash char str1[] = "0123456789";
  const char *ptr;
  __asm ("" : "=r" (ptr) : "0" (str1));
  return ptr[i];
or similar.

Reply via email to