public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/34197]  New: array overflow warning without line number
@ 2007-11-22 18:47 marcus at jet dot franken dot de
  2007-11-22 18:48 ` [Bug c/34197] " marcus at jet dot franken dot de
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: marcus at jet dot franken dot de @ 2007-11-22 18:47 UTC (permalink / raw)
  To: gcc-bugs

LANG=C /home/marcus/projects/gcc/BIN/bin/gcc  -c  -O2 -Wall -g -o xx.o
relay16.i -m32
relay16.i: In function 'f':
cc1: warning: array subscript is above array bounds


-m32 seems necessary


-- 
           Summary: array overflow warning without line number
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: marcus at jet dot franken dot de
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: i586-unknown-linux-gnu


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


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

* [Bug c/34197] array overflow warning without line number
  2007-11-22 18:47 [Bug c/34197] New: array overflow warning without line number marcus at jet dot franken dot de
@ 2007-11-22 18:48 ` marcus at jet dot franken dot de
  2007-11-22 19:28 ` rguenth at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: marcus at jet dot franken dot de @ 2007-11-22 18:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from marcus at jet dot franken dot de  2007-11-22 18:48 -------
Created an attachment (id=14612)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=14612&action=view)
relay16.i

testcase


-- 


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


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

* [Bug c/34197] array overflow warning without line number
  2007-11-22 18:47 [Bug c/34197] New: array overflow warning without line number marcus at jet dot franken dot de
  2007-11-22 18:48 ` [Bug c/34197] " marcus at jet dot franken dot de
@ 2007-11-22 19:28 ` rguenth at gcc dot gnu dot org
  2007-11-22 19:34 ` rguenth at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-11-22 19:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from rguenth at gcc dot gnu dot org  2007-11-22 19:28 -------
The expression warned about is

   call_5(D)->ret[5]

and I suspect the mapped locations make the location information wrong.


-- 

rguenth 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-11-22 19:28:25
               date|                            |


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


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

* [Bug c/34197] array overflow warning without line number
  2007-11-22 18:47 [Bug c/34197] New: array overflow warning without line number marcus at jet dot franken dot de
  2007-11-22 18:48 ` [Bug c/34197] " marcus at jet dot franken dot de
  2007-11-22 19:28 ` rguenth at gcc dot gnu dot org
@ 2007-11-22 19:34 ` rguenth at gcc dot gnu dot org
  2007-11-22 22:35 ` [Bug middle-end/34197] " mueller at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-11-22 19:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from rguenth at gcc dot gnu dot org  2007-11-22 19:34 -------
Indeed.  EXPR_LOCUS no longer is NULL if there is no location, but one has
to use EXPR_HAS_LOCATION instead.  Like

Index: tree-vrp.c
===================================================================
--- tree-vrp.c  (revision 130323)
+++ tree-vrp.c  (working copy)
@@ -4492,8 +4492,9 @@ check_all_array_refs (void)
          continue;
       }
       for (si = bsi_start (bb); !bsi_end_p (si); bsi_next (&si))
-       walk_tree (bsi_stmt_ptr (si), check_array_bounds,
-                  bsi_stmt (si), NULL);
+        if (expr_has_location (bsi_stmt (si)))
+         walk_tree (bsi_stmt_ptr (si), check_array_bounds,
+                    bsi_stmt (si), NULL);
     }
 }


which gets rid of the warning.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mueller at kde dot org


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


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

* [Bug middle-end/34197] array overflow warning without line number
  2007-11-22 18:47 [Bug c/34197] New: array overflow warning without line number marcus at jet dot franken dot de
                   ` (2 preceding siblings ...)
  2007-11-22 19:34 ` rguenth at gcc dot gnu dot org
@ 2007-11-22 22:35 ` mueller at gcc dot gnu dot org
  2007-11-22 22:40 ` mueller at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: mueller at gcc dot gnu dot org @ 2007-11-22 22:35 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from mueller at gcc dot gnu dot org  2007-11-22 22:34 -------
thanks for the analysis. I would go for a slightly more verbose version of the
same patch: 

--- gcc/tree-vrp.c      (revision 130297)
+++ gcc/tree-vrp.c      (working copy)
@@ -4339,7 +4339,7 @@ check_array_ref (tree ref, location_t* l

   low_sub = up_sub = TREE_OPERAND (ref, 1);

-  if (!up_bound || !locus || TREE_NO_WARNING (ref)
+  if (!up_bound || TREE_NO_WARNING (ref)
       || TREE_CODE (up_bound) != INTEGER_CST
       /* Can not check flexible arrays.  */
       || (TYPE_SIZE (TREE_TYPE (ref)) == NULL_TREE
@@ -4441,6 +4441,11 @@ check_array_bounds (tree *tp, int *walk_
   tree stmt = (tree)data;
   location_t *location = EXPR_LOCUS (stmt);

+  if (!EXPR_HAS_LOCATION (stmt)) {
+      *walk_subtree = FALSE;
+      return NULL_TREE;
+  }
+
   *walk_subtree = TRUE;

   if (TREE_CODE (t) == ARRAY_REF)


-- 


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


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

* [Bug middle-end/34197] array overflow warning without line number
  2007-11-22 18:47 [Bug c/34197] New: array overflow warning without line number marcus at jet dot franken dot de
                   ` (3 preceding siblings ...)
  2007-11-22 22:35 ` [Bug middle-end/34197] " mueller at gcc dot gnu dot org
@ 2007-11-22 22:40 ` mueller at gcc dot gnu dot org
  2007-11-23 23:02 ` mueller at gcc dot gnu dot org
  2007-11-23 23:11 ` mueller at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: mueller at gcc dot gnu dot org @ 2007-11-22 22:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from mueller at gcc dot gnu dot org  2007-11-22 22:40 -------
*** Bug 32546 has been marked as a duplicate of this bug. ***


-- 

mueller at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gcc at abeckmann dot de


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


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

* [Bug middle-end/34197] array overflow warning without line number
  2007-11-22 18:47 [Bug c/34197] New: array overflow warning without line number marcus at jet dot franken dot de
                   ` (4 preceding siblings ...)
  2007-11-22 22:40 ` mueller at gcc dot gnu dot org
@ 2007-11-23 23:02 ` mueller at gcc dot gnu dot org
  2007-11-23 23:11 ` mueller at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: mueller at gcc dot gnu dot org @ 2007-11-23 23:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from mueller at gcc dot gnu dot org  2007-11-23 23:02 -------
Subject: Bug 34197

Author: mueller
Date: Fri Nov 23 23:02:21 2007
New Revision: 130385

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=130385
Log:
2007-11-23  Dirk Mueller  <dmueller@suse.de>
       Richard Guenther <rguenther@suse.de>

       PR middle-end/34197
       * tree-vrp.c (check_array_ref): Move check for valid location..
       (check_array_bounds) here. Use EXPR_HAS_LOCATION().


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/tree-vrp.c


-- 


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


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

* [Bug middle-end/34197] array overflow warning without line number
  2007-11-22 18:47 [Bug c/34197] New: array overflow warning without line number marcus at jet dot franken dot de
                   ` (5 preceding siblings ...)
  2007-11-23 23:02 ` mueller at gcc dot gnu dot org
@ 2007-11-23 23:11 ` mueller at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: mueller at gcc dot gnu dot org @ 2007-11-23 23:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from mueller at gcc dot gnu dot org  2007-11-23 23:11 -------
Fixed for 4.3


-- 

mueller at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.3.0


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


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

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

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-22 18:47 [Bug c/34197] New: array overflow warning without line number marcus at jet dot franken dot de
2007-11-22 18:48 ` [Bug c/34197] " marcus at jet dot franken dot de
2007-11-22 19:28 ` rguenth at gcc dot gnu dot org
2007-11-22 19:34 ` rguenth at gcc dot gnu dot org
2007-11-22 22:35 ` [Bug middle-end/34197] " mueller at gcc dot gnu dot org
2007-11-22 22:40 ` mueller at gcc dot gnu dot org
2007-11-23 23:02 ` mueller at gcc dot gnu dot org
2007-11-23 23:11 ` 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).