public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/32546]  New: 'warning: array subscript is above/below array bounds' on delete[]
@ 2007-06-29 12:35 gcc at abeckmann dot de
  2007-07-13 11:05 ` [Bug middle-end/32546] " mueller at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: gcc at abeckmann dot de @ 2007-06-29 12:35 UTC (permalink / raw)
  To: gcc-bugs

I got the 'below array bounds' warning in some code and could reduce it to the
following testcase (which results in the 'above array bounds' warning). The
warning occurs with optimization level -O2 and above.

gcc version 4.3.0 20070622 (experimental)

g++-4.3 -c -W -Wall -O2 asiaab.cpp --save-temps
asiaab.cpp: In function 'void f()':
asiaab.cpp:5: warning: array subscript is above array bounds

================
#include <vector>
void g()
{
        std::vector<int> *A = new std::vector<int>[42];
        delete[] A;
}
================

The warning does not occur with types e.g. 'int' or 'std::pair<int,int>'
instead of 'std::vector<int>'.


-- 
           Summary: 'warning: array subscript is above/below array bounds'
                    on delete[]
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gcc at abeckmann dot de
  GCC host triplet: i486-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32546


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/32546] 'warning: array subscript is above/below array bounds' on delete[]
  2007-06-29 12:35 [Bug c++/32546] New: 'warning: array subscript is above/below array bounds' on delete[] gcc at abeckmann dot de
@ 2007-07-13 11:05 ` mueller at gcc dot gnu dot org
  2007-07-13 11:10 ` mueller at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mueller at gcc dot gnu dot org @ 2007-07-13 11:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from mueller at gcc dot gnu dot org  2007-07-13 11:05 -------
this is yet another case of the middle end folding memory arithmetics back into
an array ref that is out of bounds: 

 operator delete [] ((void *) A + 0xfffffffffffffffc);

(from orig dump)

later it is:

  D.2607_30 = &(*D.2517_7)[-4];
  operator delete [] (D.2607_30);

which will then trigger this warning (because -4 is clearly out of bounds). 


-- 

mueller at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2007-07-13 11:05:25
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32546


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/32546] 'warning: array subscript is above/below array bounds' on delete[]
  2007-06-29 12:35 [Bug c++/32546] New: 'warning: array subscript is above/below array bounds' on delete[] gcc at abeckmann dot de
  2007-07-13 11:05 ` [Bug middle-end/32546] " mueller at gcc dot gnu dot org
@ 2007-07-13 11:10 ` mueller at gcc dot gnu dot org
  2007-07-14  9:31 ` [Bug middle-end/32546] [4.3 Regression] " pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mueller at gcc dot gnu dot org @ 2007-07-13 11:10 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from mueller at gcc dot gnu dot org  2007-07-13 11:10 -------
unfortunately setting TREE_NO_WARNING on the synthesized delete[] parameters
does not help because it is lost during middle end folding


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32546


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/32546] [4.3 Regression] 'warning: array subscript is above/below array bounds' on delete[]
  2007-06-29 12:35 [Bug c++/32546] New: 'warning: array subscript is above/below array bounds' on delete[] gcc at abeckmann dot de
  2007-07-13 11:05 ` [Bug middle-end/32546] " mueller at gcc dot gnu dot org
  2007-07-13 11:10 ` mueller at gcc dot gnu dot org
@ 2007-07-14  9:31 ` pinskia at gcc dot gnu dot org
  2007-08-10  0:31 ` mmitchel at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-07-14  9:31 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
            Summary|'warning: array subscript is|[4.3 Regression] 'warning:
                   |above/below array bounds' on|array subscript is
                   |delete[]                    |above/below array bounds' on
                   |                            |delete[]
   Target Milestone|---                         |4.3.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32546


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/32546] [4.3 Regression] 'warning: array subscript is above/below array bounds' on delete[]
  2007-06-29 12:35 [Bug c++/32546] New: 'warning: array subscript is above/below array bounds' on delete[] gcc at abeckmann dot de
                   ` (2 preceding siblings ...)
  2007-07-14  9:31 ` [Bug middle-end/32546] [4.3 Regression] " pinskia at gcc dot gnu dot org
@ 2007-08-10  0:31 ` mmitchel at gcc dot gnu dot org
  2007-10-19 17:49 ` janis at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2007-08-10  0:31 UTC (permalink / raw)
  To: gcc-bugs



-- 

mmitchel at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32546


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/32546] [4.3 Regression] 'warning: array subscript is above/below array bounds' on delete[]
  2007-06-29 12:35 [Bug c++/32546] New: 'warning: array subscript is above/below array bounds' on delete[] gcc at abeckmann dot de
                   ` (3 preceding siblings ...)
  2007-08-10  0:31 ` mmitchel at gcc dot gnu dot org
@ 2007-10-19 17:49 ` janis at gcc dot gnu dot org
  2007-10-29  7:46 ` eyal at eyal dot emu dot id dot au
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: janis at gcc dot gnu dot org @ 2007-10-19 17:49 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from janis at gcc dot gnu dot org  2007-10-19 17:48 -------
I can reproduce this on powerpc64-linux with a compiler from 20070630 but not
with anything after 30070731; can anyone else still reproduce the failure, or
has it been fixed?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32546


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/32546] [4.3 Regression] 'warning: array subscript is above/below array bounds' on delete[]
  2007-06-29 12:35 [Bug c++/32546] New: 'warning: array subscript is above/below array bounds' on delete[] gcc at abeckmann dot de
                   ` (4 preceding siblings ...)
  2007-10-19 17:49 ` janis at gcc dot gnu dot org
@ 2007-10-29  7:46 ` eyal at eyal dot emu dot id dot au
  2007-11-18 18:17 ` p dot vanhoof at oma dot be
  2007-11-22 22:40 ` mueller at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: eyal at eyal dot emu dot id dot au @ 2007-10-29  7:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from eyal at eyal dot emu dot id dot au  2007-10-29 07:46 -------
(In reply to comment #3)
> I can reproduce this on powerpc64-linux with a compiler from 20070630 but not
> with anything after 30070731; can anyone else still reproduce the failure, or
> has it been fixed?

I still get it now with a C program:

#include <stdio.h>

static void f (
        char    a[3][16])
{
        printf ("%p", a[2]);
}

int main (void)
{
        char    x[3][16];

        f (x);

        return (0);
}


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32546


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/32546] [4.3 Regression] 'warning: array subscript is above/below array bounds' on delete[]
  2007-06-29 12:35 [Bug c++/32546] New: 'warning: array subscript is above/below array bounds' on delete[] gcc at abeckmann dot de
                   ` (5 preceding siblings ...)
  2007-10-29  7:46 ` eyal at eyal dot emu dot id dot au
@ 2007-11-18 18:17 ` p dot vanhoof at oma dot be
  2007-11-22 22:40 ` mueller at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: p dot vanhoof at oma dot be @ 2007-11-18 18:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from p dot vanhoof at oma dot be  2007-11-18 18:17 -------
I am not completely sure whether this is the same underlying problem, but I get
a bogus warning "array subscript is above array bounds" with the code snippet
below when compiled with gcc -c -O3 -Wall:

=================
#define N 10
extern long H[N];

long m()
{
        if( H[N-1] > 1 )
        {
                int i;
                for( i=0; i < N-1; ++i )
                        if( H[i+1] > 1 )
                                break;
                return H[i+1];
        }
        return 0;
}
=================

Note that the first if-statement guarantees that the break statement is always
executed and hence an out-of-bounds access is impossible. This is with gcc
4.3.0 20071116. This gcc version still reproduces the problem posted in comment
#4 as well.


-- 

p dot vanhoof at oma dot be changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |p dot vanhoof at oma dot be


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32546


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug middle-end/32546] [4.3 Regression] 'warning: array subscript is above/below array bounds' on delete[]
  2007-06-29 12:35 [Bug c++/32546] New: 'warning: array subscript is above/below array bounds' on delete[] gcc at abeckmann dot de
                   ` (6 preceding siblings ...)
  2007-11-18 18:17 ` p dot vanhoof at oma dot be
@ 2007-11-22 22:40 ` mueller at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: mueller at gcc dot gnu dot org @ 2007-11-22 22:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from mueller at gcc dot gnu dot org  2007-11-22 22:40 -------


*** This bug has been marked as a duplicate of 34197 ***


-- 

mueller at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32546


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2007-11-22 22:40 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-29 12:35 [Bug c++/32546] New: 'warning: array subscript is above/below array bounds' on delete[] gcc at abeckmann dot de
2007-07-13 11:05 ` [Bug middle-end/32546] " mueller at gcc dot gnu dot org
2007-07-13 11:10 ` mueller at gcc dot gnu dot org
2007-07-14  9:31 ` [Bug middle-end/32546] [4.3 Regression] " pinskia at gcc dot gnu dot org
2007-08-10  0:31 ` mmitchel at gcc dot gnu dot org
2007-10-19 17:49 ` janis at gcc dot gnu dot org
2007-10-29  7:46 ` eyal at eyal dot emu dot id dot au
2007-11-18 18:17 ` p dot vanhoof at oma dot be
2007-11-22 22:40 ` mueller at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).