mips address+symbol issue.

Michel Lespinasse walken@zoy.org
Fri Jan 23 22:28:00 GMT 2004


On Fri, Jan 23, 2004 at 11:10:51PM +0100, Erik Trulsson wrote:
> There are many ways to interpret one could interpret it, but the
> interpretation that I believe is the correct is the following:
> 
> Remember that a[i] is just syntactic sugar for *(a+i).

Should it not be syntactic sugar for *(a+(i)) instead ?

> This means that the expression a[i-2000000000L] is the same as
> *(a+i-2000000000L). With i==2000000000L, this becomes
> *(a+2000000000L-2000000000L) which is the same as
> *((a+2000000000L)-2000000000L).
> a+2000000000L is *not* a valid address, and thus undefined behaviour is
> invoked.

Do you recommend people use a[(i-2000000000L)] instead ? Sounds funny to me :)

Cheers,

-- 
Michel "Walken" Lespinasse
"In this time of war against Osama bin Laden and the oppressive
Taliban regime, we are thankful that OUR leader isn't the spoiled son
of a powerful politician from a wealthy oil family who is supported by
religious fundamentalists, operates through clandestine organizations,
has no respect for the democratic electoral process, bombs innocents,
and uses war to deny people their civil liberties." --The Boondocks



More information about the Binutils mailing list