David Brown <david.br...@hesbynett.no> wrote:

> However, the compiler has a much 
> better chance of doing bounds checking, alias checking, and other 
> optimisations on the array expression.

Why?  Either the compiler knows at compile-time that "foo" is actually
an array it has detailed information about, then it can perform
bounds-checking etc. on it, regardless which of both expressions
you're writing (assuming it performs any kind of bounds checking at
all -- I'm not sure GCC does).  However, if "foo" is a pointer of
unknown source, no checks can be applied regardless of whether you're
writing &foo[i] or foo + i.  (Some optimizations can be applied if foo
is a pointer passed as a function argument, and qualified "restrict".)

> Additionally, &foo[i] and (foo + i) read as different things (one is
> the address of an element, the other is the address of an array plus
> an offset).

However, given the way an offset is computed in C, the result is
again: the address of an element (possibly an element of a dynamic
array).

-- 
cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)


_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Reply via email to