[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Re: sprintf
From: |
Joerg Wunsch |
Subject: |
Re: [avr-gcc-list] Re: sprintf |
Date: |
Thu, 5 Mar 2009 06:24:29 +0100 (MET) |
David Brown <address@hidden> 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. ;-)
- Re: [avr-gcc-list] Re: sprintf, (continued)
- Re: [avr-gcc-list] Re: sprintf, David Kelly, 2009/03/02
- Re: [avr-gcc-list] Re: sprintf, Joerg Wunsch, 2009/03/03
- Re: [avr-gcc-list] Re: sprintf, Joerg Wunsch, 2009/03/03
- [avr-gcc-list] Re: sprintf, David Brown, 2009/03/03
- Re: [avr-gcc-list] Re: sprintf, Pertti Kellomäki, 2009/03/03
- Re: [avr-gcc-list] Re: sprintf, Georg-Johann Lay, 2009/03/03
- Re: [avr-gcc-list] Re: sprintf,
Joerg Wunsch <=
- [avr-gcc-list] Re: sprintf, David Brown, 2009/03/05
- Re: [avr-gcc-list] Re: sprintf, Joerg Wunsch, 2009/03/06
- [avr-gcc-list] Re: sprintf, David Brown, 2009/03/06
- RE: [avr-gcc-list] Re: sprintf, Weddington, Eric, 2009/03/06