This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/83805] [8 Regression] Wrong constant merging for objects in different address spaces
- From: "jakub at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 11 Jan 2018 16:45:31 +0000
- Subject: [Bug middle-end/83805] [8 Regression] Wrong constant merging for objects in different address spaces
- Auto-submitted: auto-generated
- References: <bug-83805-4@http.gcc.gnu.org/bugzilla/>
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.