public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/46759] New: incorrect array bounds warning?
@ 2010-12-02  1:12 rwgk at yahoo dot com
  2010-12-02  1:29 ` [Bug c++/46759] " redi at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: rwgk at yahoo dot com @ 2010-12-02  1:12 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: incorrect array bounds warning?
           Product: gcc
           Version: 4.5.1
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: rwgk@yahoo.com


Created attachment 22598
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22598
small reproducer

Linux theta.lbl.gov 2.6.35.6-48.fc14.x86_64 #1 SMP Fri Oct 22 15:36:08 UTC 2010
x86_64 x86_64 x86_64 GNU/Linux
g++ (GCC) 4.5.1 20100924 (Red Hat 4.5.1-4)

g++ -Wall -O1 ~/bounds_warning.cpp # no warning

g++ -Wall -O2 ~/bounds_warning.cpp
bounds_warning.cpp: In function 'int main()':
bounds_warning.cpp:21:14: warning: array subscript is above array bounds

I stared at this for a while but couldn't find a problem with my code.

Is there maybe a problem with the optimizer?

Unfortunately I've been unable to bootstrap the 4.5 branch or the trunk.
Could someone try out the attached reproducer against the current svn
of the branch/trunk?


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

* [Bug c++/46759] incorrect array bounds warning?
  2010-12-02  1:12 [Bug c++/46759] New: incorrect array bounds warning? rwgk at yahoo dot com
@ 2010-12-02  1:29 ` redi at gcc dot gnu.org
  2010-12-02  1:32 ` pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2010-12-02  1:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2010-12-02 01:29:13 UTC ---
With 4.4.4 20100630 (Red Hat 4.4.4-10) I get the array bounds warning twice.
With 4.5.2 20101101 I get it once
With 4.6.0 20101128 I get no warning


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

* [Bug c++/46759] incorrect array bounds warning?
  2010-12-02  1:12 [Bug c++/46759] New: incorrect array bounds warning? rwgk at yahoo dot com
  2010-12-02  1:29 ` [Bug c++/46759] " redi at gcc dot gnu.org
@ 2010-12-02  1:32 ` pinskia at gcc dot gnu.org
  2010-12-02 19:47 ` rwgk at yahoo dot com
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2010-12-02  1:32 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> 2010-12-02 01:32:25 UTC ---
I think there be a change of having above array bounds.  Though it is hard to
see from the source really.  The issue happens when the first loop goes through
without hitting a null character in the rhs.


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

* [Bug c++/46759] incorrect array bounds warning?
  2010-12-02  1:12 [Bug c++/46759] New: incorrect array bounds warning? rwgk at yahoo dot com
  2010-12-02  1:29 ` [Bug c++/46759] " redi at gcc dot gnu.org
  2010-12-02  1:32 ` pinskia at gcc dot gnu.org
@ 2010-12-02 19:47 ` rwgk at yahoo dot com
  2010-12-05  7:08 ` rwgk at yahoo dot com
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rwgk at yahoo dot com @ 2010-12-02 19:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from rwgk at yahoo dot com 2010-12-02 19:47:29 UTC ---
Created attachment 22606
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22606
reproducer with additional tests

I changed the original reproducer to return 0 through 4 instead of true or
false to verify that each branch is exercised with added tests. The output is
as expected and valgrind doesn't report problems. Therefore I still believe the
warning misfires.

Assuming my code holds up under further scrutinization:
It clearly is a minor problem but it creates distracting noise. If it is too
much trouble to fix in the 4.5 branch, could the example be added to the test
suite in the trunk, so that the same problem doesn't crop up again in the
future?


% valgrind a.out                          ==20636== Memcheck, a memory error
detector
==20636== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
==20636== Using Valgrind-3.5.0 and LibVEX; rerun with -h for copyright info
==20636== Command: a.out
==20636==
0
0
1
1
2
2
3
3
4
4
4
==20636==
==20636== HEAP SUMMARY:
==20636==     in use at exit: 0 bytes in 0 blocks
==20636==   total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==20636==
==20636== All heap blocks were freed -- no leaks are possible
==20636==
==20636== For counts of detected and suppressed errors, rerun with: -v
==20636== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 6 from 6)


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

* [Bug c++/46759] incorrect array bounds warning?
  2010-12-02  1:12 [Bug c++/46759] New: incorrect array bounds warning? rwgk at yahoo dot com
                   ` (2 preceding siblings ...)
  2010-12-02 19:47 ` rwgk at yahoo dot com
@ 2010-12-05  7:08 ` rwgk at yahoo dot com
  2011-01-25 23:56 ` LpSolit at netscape dot net
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rwgk at yahoo dot com @ 2010-12-05  7:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from rwgk at yahoo dot com 2010-12-05 06:14:35 UTC ---
Created attachment 22639
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22639
reproducer for similar warning from gcc 4.6

I'm getting a similar warning with g++ from the current svn trunk:

svn trunk rev. 167466

g++ (GCC) 4.6.0 20101205 (experimental)

% g++ -Wall -O3 pr46759_bounds_warning_2.cpp
pr46759_bounds_warning_2.cpp: In function 'int main()':
pr46759_bounds_warning_2.cpp:11:3: warning: array subscript is above array
bounds [-Warray-bounds]

The reproducer is attached.
g++ 4.5.1 doesn't emit a warning.
Would it be better to file this as a new bug?


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

* [Bug c++/46759] incorrect array bounds warning?
  2010-12-02  1:12 [Bug c++/46759] New: incorrect array bounds warning? rwgk at yahoo dot com
                   ` (3 preceding siblings ...)
  2010-12-05  7:08 ` rwgk at yahoo dot com
@ 2011-01-25 23:56 ` LpSolit at netscape dot net
  2011-03-26 16:15 ` aj664 at hotmail dot com
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: LpSolit at netscape dot net @ 2011-01-25 23:56 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from rwgk at yahoo dot com 2010-12-05 06:14:35 UTC ---
Created attachment 22639
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22639
reproducer for similar warning from gcc 4.6

I'm getting a similar warning with g++ from the current svn trunk:

svn trunk rev. 167466

g++ (GCC) 4.6.0 20101205 (experimental)

% g++ -Wall -O3 pr46759_bounds_warning_2.cpp
pr46759_bounds_warning_2.cpp: In function 'int main()':
pr46759_bounds_warning_2.cpp:11:3: warning: array subscript is above array
bounds [-Warray-bounds]

The reproducer is attached.
g++ 4.5.1 doesn't emit a warning.
Would it be better to file this as a new bug?


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

* [Bug c++/46759] incorrect array bounds warning?
  2010-12-02  1:12 [Bug c++/46759] New: incorrect array bounds warning? rwgk at yahoo dot com
                   ` (4 preceding siblings ...)
  2011-01-25 23:56 ` LpSolit at netscape dot net
@ 2011-03-26 16:15 ` aj664 at hotmail dot com
  2011-03-26 17:15 ` aj664 at hotmail dot com
  2013-05-04 10:48 ` paolo.carlini at oracle dot com
  7 siblings, 0 replies; 9+ messages in thread
From: aj664 at hotmail dot com @ 2011-03-26 16:15 UTC (permalink / raw)
  To: gcc-bugs

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

AJ <aj664 at hotmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |aj664 at hotmail dot com

--- Comment #5 from AJ <aj664 at hotmail dot com> 2011-03-26 15:59:21 UTC ---
not sure if this will help.
but i found this problem with -O2 optimzed code in GCC 4.5.1  (and 4.4.1)

example to show the kind of problem (not a literal testcase)

int a[8];
a[4] = 9;

issues an   array-bounds warning,  -Warray-bounds
seems to be confusing the array elements value with the array size.
if i have

a[4] = 7;

no error.
I hope that gives someone an idea about where to look for the problem.
(i haven't access to newer GCCs)


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

* [Bug c++/46759] incorrect array bounds warning?
  2010-12-02  1:12 [Bug c++/46759] New: incorrect array bounds warning? rwgk at yahoo dot com
                   ` (5 preceding siblings ...)
  2011-03-26 16:15 ` aj664 at hotmail dot com
@ 2011-03-26 17:15 ` aj664 at hotmail dot com
  2013-05-04 10:48 ` paolo.carlini at oracle dot com
  7 siblings, 0 replies; 9+ messages in thread
From: aj664 at hotmail dot com @ 2011-03-26 17:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from AJ <aj664 at hotmail dot com> 2011-03-26 16:56:19 UTC ---
(In reply to comment #5)

ignore my comments. i can't confirm it sufficiently. i might be wrong.


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

* [Bug c++/46759] incorrect array bounds warning?
  2010-12-02  1:12 [Bug c++/46759] New: incorrect array bounds warning? rwgk at yahoo dot com
                   ` (6 preceding siblings ...)
  2011-03-26 17:15 ` aj664 at hotmail dot com
@ 2013-05-04 10:48 ` paolo.carlini at oracle dot com
  7 siblings, 0 replies; 9+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-05-04 10:48 UTC (permalink / raw)
  To: gcc-bugs


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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
      Known to work|                            |4.8.0, 4.9.0
         Resolution|                            |FIXED

--- Comment #7 from Paolo Carlini <paolo.carlini at oracle dot com> 2013-05-04 10:48:00 UTC ---
Cannot reproduce with active branches. If you can still see something wrong
please re-open or file a new issue. Thanks.


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

end of thread, other threads:[~2013-05-04 10:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-02  1:12 [Bug c++/46759] New: incorrect array bounds warning? rwgk at yahoo dot com
2010-12-02  1:29 ` [Bug c++/46759] " redi at gcc dot gnu.org
2010-12-02  1:32 ` pinskia at gcc dot gnu.org
2010-12-02 19:47 ` rwgk at yahoo dot com
2010-12-05  7:08 ` rwgk at yahoo dot com
2011-01-25 23:56 ` LpSolit at netscape dot net
2011-03-26 16:15 ` aj664 at hotmail dot com
2011-03-26 17:15 ` aj664 at hotmail dot com
2013-05-04 10:48 ` paolo.carlini at oracle dot com

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).