Checking of constant bounds in array access

Wolfgang Bangerth wolf@gaia.iwr.uni-heidelberg.de
Wed Jul 1 05:54:00 GMT 1998


Hi there,

this probably has been asked before; if so please excuse, I didn't search
the archives too extensively. My question is: would it be possible for the
compiler to generate a warning on the following code snippet:
----------------------------------------------------------------------
void f() {
  int a[10];
  a[1000] = 1;
  a[-100] = 1;
};
----------------------------------------------------------------------
Bounds and indices are known to the compiler, so it should be possible to
catch this kind of problem.

Regards,
  Wolfgang




More information about the Gcc-bugs mailing list