Re: gcc 4.8.1: -O2 warnings one element off

2013-06-01 Thread Jens Bauer
On Sat, 01 Jun 2013 22:12:51 +0100, Andrew Haley wrote: > In both cases you cannot actually use the memory at *p. I think gcc is > detecting the indexing but not the access. That makes sense! On Sat, 1 Jun 2013 23:19:45 +0200, Jakub Jelinek wrote: > It is not a bug, the warning isn't guaranteed

Re: gcc 4.8.1: -O2 warnings one element off

2013-06-01 Thread Jakub Jelinek
On Sat, Jun 01, 2013 at 11:08:21PM +0200, Jens Bauer wrote: > Here's my result: > > ---8<-8<-8<- > elementTest.c: In function 'main': > elementTest.c:27:19: warning: iteration 8u invokes undefined behavior > [-Waggressive-loop-optimizations] >eightMembers[i] = 0; >

Re: gcc 4.8.1: -O2 warnings one element off

2013-06-01 Thread Andrew Haley
On 06/01/2013 10:08 PM, Jens Bauer wrote: > I would expect gcc to complain when it meets the second loop as well as the > third loop, but it didn't detect that there is something wrong with the > second loop. > > ...Is this a bug ? C allows you to index one element beyond the end of an array.

gcc 4.8.1: -O2 warnings one element off

2013-06-01 Thread Jens Bauer
Hi list. I think I've found a bug in where gcc checks if array indices are in range. Here's my test-code: ---8<-8<-8<- /* * file: elementTest.c * command-line: * arm-none-eabi-gcc -O2 elementTest.c -o elementTest */ #include uint8_t eightMembers[8]; int main(int argc, const