This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Really, really const
- From: Andrew Haley <aph at redhat dot com>
- To: gcc at gcc dot gnu dot org
- Date: Fri, 26 Sep 2003 08:01:04 +0100
- Subject: Really, really const
I'm trying to persuade gcc that a memory area is unchanging. Consider
this:
extern const int a[];
extern void f();
int foo ()
{
int n = a[0];
f();
n += a[0];
return n;
}
Now, I know that a[0] can't change. But is there any way to tell gcc
that i can't change? const doesn't seem to do it:
movl a, %ebx
call f
addl a, %ebx
The memory a[0] is read twice. Is there any attrribute I can use to
stop gcc from doing this?
Andrew.