From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 477 invoked by alias); 26 Sep 2011 07:14:14 -0000 Received: (qmail 445 invoked by uid 22791); 26 Sep 2011 07:14:11 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,MSGID_MULTIPLE_AT,SPF_SOFTFAIL X-Spam-Check-By: sourceware.org Received: from service87.mimecast.com (HELO service87.mimecast.com) (91.220.42.44) by sourceware.org (qpsmtpd/0.43rc1) with SMTP; Mon, 26 Sep 2011 07:13:57 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Mon, 26 Sep 2011 08:13:55 +0100 Received: from jiangningsh02 ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 26 Sep 2011 08:13:52 +0100 From: "Jiangning Liu" To: "Jiangning Liu" , Cc: , , , "Matthew Gretton-Dann" References: In-Reply-To: Subject: RE: A question about detecting array bounds for case Warray-bounds-3.c Date: Mon, 26 Sep 2011 08:32:00 -0000 Message-ID: <000801cc7c1b$d5099d00$7f1cd700$@liu@arm.com> MIME-Version: 1.0 X-MC-Unique: 111092608135501501 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2011-09/txt/msg00303.txt.bz2 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 >=20 > Hi, >=20 > 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 "<=3D". >=20 > Right now, GCC compiler doesn't report any warning messages for this > case, should it be a bug in both test case and compiler? >=20 > But looking at http://gcc.gnu.org/PR31227 , it seems this test case is > designed to be like this on purpose. Anybody can explain about this? >=20 > The case is like below, >=20 > /* { dg-do compile } */ > /* { dg-options "-O2 -Warray-bounds" } */ > /* based on PR 31227 */ >=20 > struct S > { > const char *abday[7]; > const char *day[7]; > const char *abmon[12]; > const char *mon[12]; > const char *am_pm[2]; > }; >=20 > ... >=20 > for (cnt =3D 0; cnt <=3D 7; ++cnt) > { > iov[2 + cnt].iov_base =3D (void *) (time->abday[cnt] ?: ""); > iov[2 + cnt].iov_len =3D strlen (iov[2 + cnt].iov_base) + 1; > } >=20 > for (; cnt <=3D 14; ++cnt) > { > iov[2 + cnt].iov_base =3D (void *) (time->day[cnt - 7] ?: ""); > iov[2 + cnt].iov_len =3D strlen (iov[2 + cnt].iov_base) + 1; > } >=20 > for (; cnt <=3D 26; ++cnt) > { > iov[2 + cnt].iov_base =3D (void *) (time->abmon[cnt - 14] ?: ""); > iov[2 + cnt].iov_len =3D strlen (iov[2 + cnt].iov_base) + 1; > } >=20 > for (; cnt <=3D 38; ++cnt) > { > iov[2 + cnt].iov_base =3D (void *) (time->mon[cnt - 26] ?: ""); > iov[2 + cnt].iov_len =3D strlen (iov[2 + cnt].iov_base) + 1; > } >=20 > for (; cnt <=3D 40; ++cnt) > { > iov[2 + cnt].iov_base =3D (void *) (time->am_pm[cnt - 38] ?: ""); > iov[2 + cnt].iov_len =3D strlen (iov[2 + cnt].iov_base) + 1; > } >=20 > Thanks, > -Jiangning