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: "law at redhat dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 21 Jun 2005 01:20:21 -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 law at redhat dot com 2005-06-21 01:20 -------
Subject: Re: no compile time array index checking
On Tue, 2005-06-21 at 00:10 +0000, giovannibajo at libero dot it wrote:
> ------- Additional Comments From giovannibajo at libero dot it 2005-06-21 00:10 -------
> Doesn't -fmudflap handle this?
I would expect mudflap to issue a runtime warning.
If we really wanted to tackle this better a compile-time, we'd run a
pass to look at all the ARRAY_REFs for those which have an out-of-range
index. It wouldn't be terribly hard to stick one in just before we
leave SSA form.
Doing it that way has a number of useful advantages -- we'll see a
lot more ARRAY_REFs rather than pointer arithmetic (due to constant
address propagation as well as ADDR_EXPR propagation). We'll also
see more constant indices due to const propagation done by CCP,
VRP and DOM. And (of course) it would "just work" for all the
languages currently supported by GCC.
I believe Jakub has done some work in this area that might be useful
as a starting point.
jeff
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8268