This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gcc 4.8.1: -O2 warnings one element off


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.  So, this

  uint8_t eightMembers[8];
  uint8_t *p = &eightMembers[8];

is legal, but

  uint8_t eightMembers[8];
  uint8_t *p = &eightMembers[9];

is not.

In both cases you cannot actually use the memory at *p.  I think gcc is
detecting the indexing but not the access.

Andrew.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]