This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/8268] no compile time array index checking
- From: "trt at acm dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 21 Jun 2005 15:55:52 -0000
- Subject: [Bug c/8268] no compile time array index checking
- References: <20021017142600.8268.d.binderman@virgin.net>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From trt at acm dot org 2005-06-21 15:55 -------
Since there is mudflap, it is especially important to avoid false positives.
One type occurs in code that never actually executes, e.g. conditional lookup:
#define LOOKUP(i) (i < XSIZE ? x[i]: 0)
To defend against that, issue the warning only if skip_evaluation is zero.
(For a more general fix, see http://gcc.gnu.org/ml/gcc/2004-10/msg00859.html)
Another is taking the address one past the last element, e.g.
int a[10];
int *aend = &a[10]; // this is perfectly valid, and common
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8268