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]

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


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