This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
GCC and out-of-range constant array indexes?
- From: Gary Funck <gary at intrepid dot com>
- To: GCC List <gcc at gcc dot gnu dot org>
- Date: Thu, 7 Oct 2010 21:12:10 -0700
- Subject: GCC and out-of-range constant array indexes?
Consider the following:
$ cat -n t.c
1
2 int A[10] = { 0 };
3
4 int main()
5 {
6 A[10] = 10;
7 A[-1] = -1;
8 return 0;
9 }
In a compiler test case that I reviewed recently, there was the
expectation that the compiler would issue a compile-time warning
on the statements at lines 6 an 7 above. I tried this with
GCC version "gcc (GCC) 4.4.4 20100630 (Red Hat 4.4.4-10)"
recently and was unable to find compilation switches that
would cause it to complain about the use of out-of-range
indexes above.
Is there a technical reason that the compiler should not
issue a warning, or might this feature become a legitimate RFE?
thanks,
- Gary