This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/83805] [8 Regression] Wrong constant merging for objects in different address spaces


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]