This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c/8268: no compile time array index checking
- From: "David Binderman" <d dot binderman at virgin dot net>
- To: <bangerth at dealii dot org>,<gcc-prs at gcc dot gnu dot org>,<nobody at gcc dot gnu dot org>,<gcc-gnats at gcc dot gnu dot org>,<gcc-bugs at gcc dot gnu dot org>
- Date: Sun, 26 Jan 2003 16:08:53 -0000
- Subject: Re: c/8268: no compile time array index checking
- References: <20030108024003.15913.qmail@sources.redhat.com>
Hello there,
I tried out the suggested patch, and it seems ok, until I run
the gcc test suite, where I get problems on test
gcc.c-torture/execute/20010924-1.c
as shown
(gdb) r /tmp/1.i
Starting program:
/home/dcb/gnu/gcc321/results.check/lib/gcc-lib/i686-pc-linux-gnu/3.2.1/cc1
/tmp/1.i
main
Program received signal SIGSEGV, Segmentation fault.
0x080f12d3 in get_inner_reference (exp=0x40271700, pbitsize=0xbffff1ec,
pbitpos=0xbffff1f0, poffset=0xbffff1f4, pmode=0x0,
punsignedp=0x40016c60,
pvolatilep=0xbffff1fc) at ../../src/gcc-3.2.1/gcc/expr.c:5338
5338 || (TREE_CODE (TYPE_MAX_VALUE (domain)) ==
INTEGER_CST(gdb) list
5333
5334 if (domain && TREE_CODE (index) == INTEGER_CST)
5335 {
5336 if ((TREE_CODE (low_bound) == INTEGER_CST
5337 && tree_int_cst_lt(index, low_bound))
5338 || (TREE_CODE (TYPE_MAX_VALUE (domain)) ==
INTEGER_CST5339 && tree_int_cst_lt (TYPE_MAX_VALUE
(domain), index)
5340 /* Accesses after the end of arrays of size 0
(gcc5341 extension) and 1 are likely
intentional. */
5342 && !tree_int_cst_lt (TYPE_MAX_VALUE (domain),
(gdb)
Further, it seems a good idea if the warning message produced could be
enhanced to give a clue about the index value and the size of the array.
Something like
warning: array index '10' in array 'fred' of size '5' is not valid.
A possible second enhancement is to make sure that all six bugs in my
original demonstration case are found. The current version of the patch
only finds four of the six problems.
The supplied patch does seem to find bugs in the gcc321 source code,
however.
Regards
dcb
----- Original Message -----
From: <bangerth@dealii.org>
To: <d.binderman@virgin.net>; <gcc-bugs@gcc.gnu.org>; <gcc-prs@gcc.gnu.org>;
<nobody@gcc.gnu.org>
Sent: Wednesday, January 08, 2003 2:40 AM
Subject: Re: c/8268: no compile time array index checking
> Synopsis: no compile time array index checking
>
> State-Changed-From-To: open->analyzed
> State-Changed-By: bangerth
> State-Changed-When: Tue Jan 7 18:40:02 2003
> State-Changed-Why:
> Valid request. Falk even has a patch for that, but it
> does not seem to be in.
>
> In fact, the category should not be accepts-illegal, since
> the code is perfectly legal. It just does something
> undefined.
>
> W.
>
>
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&p
r=8268
>