This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
gcc-4.8-20121028 array bound check
- From: "Nately at t-online dot de" <Nately at t-online dot de>
- To: gcc at gcc dot gnu dot org
- Date: Mon, 29 Oct 2012 11:56:06 +0100
- Subject: gcc-4.8-20121028 array bound check
- Reply-to: "Nately at t-online dot de" <Nately at t-online dot de>
I find this array bound check too hard:
./compiler/gcc-4.8.0-snap/bin/gcc c1.c -O3 -c -Wall
c1.c: In function ?main?:
c1.c:15:22: warning: array subscript is above array bounds
[-Warray-bounds]
?????????? if (!ab_pid[index])
????????????????????? ^
extern unsigned char ab_pid_count,old_rfcb_pid_count;
extern unsigned short ab_pid[16];
extern int found_pid;
int main()
{
? unsigned char pid_index = 0;
? int index;
? for (pid_index=0; (pid_index < old_rfcb_pid_count); pid_index++)
??? {
????? for (index=0; index < ab_pid_count; index++)
??????? {
????????? if (!ab_pid[index])
??????????? {
????????????? found_pid = 1;
??????????? }
??????? };
??? }
? return 0;
}
Does this mean we have to rework the loops like 'index < ab_pid_count &&
index < 16' ? But if so, why does the warning disappear without the
outer loop or with ' unsigned short ab_pid[32]'?
Regards.