This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: mips address+symbol issue.
At 23 Jan 2004 16:20:27 -0500, Ian Lance Taylor wrote:
> (My understanding is that the C standard doesn't even permit you to
> form the address of an out-of-bounds array access. Doing so moves you
> out of the range of standardized behaviour, and no promises are made.)
FWIW, looking at the test case, and not being a language lawyer, i
don't know that it *does* form the address of an out-of-bounds array
access.
the test case is:
char a[10] = "deadbeef";
char
acc_a (long i)
{
return a[i-2000000000L];
}
main ()
{
if (acc_a (2000000000L) != 'd')
abort ();
exit (0);
}
Two ways to interpret this, i guess:
long tmp;
tmp = i - 2000000000L;
return a[tmp];
and:
char *tmp;
tmp = &a[-2000000000L];
return *(tmp + i); // or just: return tmp[i];
I'd suspect the former is what the order of operations would require,
but the latter is what the compiler's emitting as assembly code.
chris