Really, really const
Andrew Haley
aph@redhat.com
Fri Sep 26 08:18:00 GMT 2003
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.
More information about the Gcc
mailing list