This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: A question about detecting array bounds for case Warray-bounds-3.c
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Jiangning Liu <jiangning dot liu at arm dot com>
- Cc: gcc at gcc dot gnu dot org, jakub at gcc dot gnu dot org, mueller at gcc dot gnu dot org, rguenth at gcc dot gnu dot org, Matthew Gretton-Dann <Matthew dot Gretton-Dann at arm dot com>
- Date: Mon, 26 Sep 2011 10:03:26 +0100
- Subject: Re: A question about detecting array bounds for case Warray-bounds-3.c
- References: <4e80264f.6ab8ec0a.78ce.ffffad1cSMTPIN_ADDED@mx.google.com>
On 26 September 2011 08:13, Jiangning Liu wrote:
> PING...
>
>> -----Original Message-----
>> From: Jiangning Liu [mailto:jiangning.liu@arm.com]
>> Sent: Thursday, September 22, 2011 10:19 AM
>> To: gcc@gcc.gnu.org
>> Cc: 'jakub@gcc.gnu.org'; 'mueller@gcc.gnu.org'; 'rguenth@gcc.gnu.org';
>> Matthew Gretton-Dann
>> Subject: A question about detecting array bounds for case Warray-
>> bounds-3.c
>>
>> Hi,
>>
>> For case gcc/testsuite/gcc.dg/Warray-bounds-3.c, obviously it is an
>> invalid C program, because the last iterations of all the loops cause
>> the access of arrays is beyond the max size of corresponding array
>> declarations. The condition of checking upper bound should be "<"
>> rather than "<=".
Which loops are you referring to?
struct iovec iov[43];
...
for (; cnt <= 40; ++cnt)
{
iov[2 + cnt].iov_base = (void *) (time->am_pm[cnt - 38] ?: "");
iov[2 + cnt].iov_len = strlen (iov[2 + cnt].iov_base) + 1;
}
What's wrong with that? The last element accessed is iov[42] which is ok.