[Bug bootstrap/30511] False array bound check causes gcc failed to boostrap

2007-01-30 Thread mueller at gcc dot gnu dot org


--- Comment #9 from mueller at gcc dot gnu dot org  2007-01-30 17:18 ---
Subject: Bug 30511

Author: mueller
Date: Tue Jan 30 17:17:39 2007
New Revision: 121346

URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=121346
Log:
backport from mainline:

  2007-01-21  Dirk Mueller  [EMAIL PROTECTED]

PR bootstrap/30511
* tree-vrp.c (check_array_bounds): do not warn
about ADDR_EXPR's of ARRAY_REF's which are immediately
used in binary expressions.

  2007-01-19  Dirk Mueller  [EMAIL PROTECTED]

* config/i386.h (CONDITIONAL_REGISTER_USAGE): Store
result of PIC_OFFSET_TABLE_REGNUM in temporary variable to avoid
duplicate evaluation.

  2007-01-18  Dirk Mueller  [EMAIL PROTECTED]
Richard Guenther [EMAIL PROTECTED]

PR diagnostic/8268
* doc/invoke.texi (Warray-bounds): Document -Warray-bounds.
* common.opt (Warray-bounds): Add new warning option.
* c-opts.c (c_common_handle_option): Define -Warray-bounds
if -Wall is given.
* Makefile.in: make tree-vrp.o depend on toplev.h
* tree-vrp.c (vrp_finalize): Call check_array_refs if
* -Warray-bounds
is enabled.
(check_array_refs, check_array_bounds, check_array_ref): New.


Added:
branches/suse/gcc-4_2-branch/gcc/testsuite/g++.dg/warn/Warray-bounds-2.C
  - copied unchanged from r120898,
trunk/gcc/testsuite/g++.dg/warn/Warray-bounds-2.C
branches/suse/gcc-4_2-branch/gcc/testsuite/g++.dg/warn/Warray-bounds.C
  - copied unchanged from r120898,
trunk/gcc/testsuite/g++.dg/warn/Warray-bounds.C
branches/suse/gcc-4_2-branch/gcc/testsuite/gcc.dg/Warray-bounds-2.c
  - copied unchanged from r120898,
trunk/gcc/testsuite/gcc.dg/Warray-bounds-2.c
branches/suse/gcc-4_2-branch/gcc/testsuite/gcc.dg/Warray-bounds.c
  - copied unchanged from r120898,
trunk/gcc/testsuite/gcc.dg/Warray-bounds.c
Modified:
branches/suse/gcc-4_2-branch/gcc/Makefile.in
branches/suse/gcc-4_2-branch/gcc/c-opts.c
branches/suse/gcc-4_2-branch/gcc/common.opt
branches/suse/gcc-4_2-branch/gcc/config/i386/i386.h
branches/suse/gcc-4_2-branch/gcc/doc/invoke.texi
branches/suse/gcc-4_2-branch/gcc/tree-vrp.c


-- 


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



[Bug bootstrap/30511] False array bound check causes gcc failed to boostrap

2007-01-21 Thread mueller at gcc dot gnu dot org


--- Comment #7 from mueller at gcc dot gnu dot org  2007-01-21 16:12 ---
Subject: Bug 30511

Author: mueller
Date: Sun Jan 21 16:12:10 2007
New Revision: 121032

URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=121032
Log:
2007-01-21  Dirk Mueller  [EMAIL PROTECTED]

PR bootstrap/30511
* tree-vrp.c (check_array_bounds): do not warn
about ADDR_EXPR's of ARRAY_REF's which are immediately
used in binary expressions.

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


-- 


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



[Bug bootstrap/30511] False array bound check causes gcc failed to boostrap

2007-01-21 Thread mueller at gcc dot gnu dot org


--- Comment #8 from mueller at gcc dot gnu dot org  2007-01-21 16:52 ---
Fixed for 4.3. 


-- 

mueller at gcc dot gnu dot org changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution||FIXED


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



[Bug bootstrap/30511] False array bound check causes gcc failed to boostrap

2007-01-20 Thread dominiq at lps dot ens dot fr


--- Comment #6 from dominiq at lps dot ens dot fr  2007-01-20 13:27 ---
On Mac OSX 10.3.9, after the same failure I have applied the patch of comment
#1. Now the build fails
with:

/sw/src/fink.build/gcc4-4.3.0-20070120/darwin_objdir/./gcc/xgcc
-B/sw/src/fink.build/gcc4-4.3.0-20070120/darwin_objdir/./gcc/
-B/sw/lib/gcc4/powerpc-apple-darwin7/bin/
-B/sw/lib/gcc4/powerpc-apple-darwin7/lib/ -isystem
/sw/lib/gcc4/powerpc-apple-darwin7/include -isystem
/sw/lib/gcc4/powerpc-apple-darwin7/sys-include -DHAVE_CONFIG_H -I.
-I../../../gcc-4.3-20070120/libgfortran -I.
-iquote../../../gcc-4.3-20070120/libgfortran/io
-I../../../gcc-4.3-20070120/libgfortran/../gcc
-I../../../gcc-4.3-20070120/libgfortran/../gcc/config -I../.././gcc
-D_GNU_SOURCE -std=gnu99 -Wall -Wstrict-prototypes -Wmissing-prototypes
-Wold-style-definition -Wextra -Wwrite-strings -O2 -g -O2 -MT error.lo -MD -MP
-MF .deps/error.Tpo -c ../../../gcc-4.3-20070120/libgfortran/runtime/error.c 
-fno-common -DPIC -o .libs/error.o
In file included from ../../../gcc-4.3-20070120/libgfortran/runtime/error.c:52:
/usr/include/sys/resource.h:81: error: field 'ru_utime' has incomplete type
/usr/include/sys/resource.h:82: error: field 'ru_stime' has incomplete type

Any idea?


-- 


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



[Bug bootstrap/30511] False array bound check causes gcc failed to boostrap

2007-01-19 Thread mueller at gcc dot gnu dot org


--- Comment #1 from mueller at gcc dot gnu dot org  2007-01-19 20:04 ---
this patch fixes / works around it. I don't like it yet, I'm trying to find a
better solution. 

--- tree-vrp.c  (revision 120953)
+++ tree-vrp.c  (working copy)
@@ -3583,6 +3583,25 @@ check_array_bounds (tree *tp, int *walk_
*walk_subtree = FALSE;
return NULL_TREE;
  }
+
+   /* Don't warn if the result ssa_name is used in another
+ binary expr.  */
+   if (TREE_CODE ((tree)data) == GIMPLE_MODIFY_STMT
+GIMPLE_STMT_OPERAND ((tree)data, 0)
+TREE_CODE (GIMPLE_STMT_OPERAND ((tree)data, 0)) == SSA_NAME)
+ {
+  imm_use_iterator iter;
+  tree lhs = GIMPLE_STMT_OPERAND ((tree)data, 0);
+  tree use;
+
+  FOR_EACH_IMM_USE_STMT (use, iter, lhs)
+if (TREE_CODE (use) == GIMPLE_MODIFY_STMT
+ BINARY_CLASS_P (GIMPLE_STMT_OPERAND (use, 1)))
+  *walk_subtree = FALSE;
+
+  if (*walk_subtree == FALSE)
+return NULL_TREE;
+ }
while (handled_component_p (t))
  {
if (TREE_CODE (t) == ARRAY_REF)


-- 

mueller at gcc dot gnu dot org changed:

   What|Removed |Added

 Status|UNCONFIRMED |ASSIGNED
 Ever Confirmed|0   |1
   Last reconfirmed|-00-00 00:00:00 |2007-01-19 20:04:36
   date||


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



[Bug bootstrap/30511] False array bound check causes gcc failed to boostrap

2007-01-19 Thread roger at eyesopen dot com


--- Comment #2 from roger at eyesopen dot com  2007-01-19 20:55 ---

It looks like the ivopts pass is creating dubious? array references.
The symbol.c.053t.vrp1

  D.12252_12 = (long unsigned int) i_2;
  D.12255_15 = ns_4-default_type[D.12252_12];
  ts_16 = D.12255_15 + -2328B;

i.e. we now have ns-default_type[i] - ns-default_type['a'].
I wouldn't like to offer an opinion on whether this IV is valid in the
middle-end.  The transformation is certainly unsafe in C, where a pointer
arithmetic is not guaranteed to be valid outside of the declared object.

I think the appropriate fix is that if ivopts is going to create these
suspicious array refs, it should appropriately set TREE_NO_WARNING, which
will then cause the reference to be ignored by the bounds checking in VRP.

Alternatively, we need more context in array bounds checking such that
x['a'] is not a problem, but x['a'] on it's own is diagnosed.  i.e. we
could perhaps keep an in_indirect_ref_p flag during the tree walking.

I hope this helps.


-- 


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



[Bug bootstrap/30511] False array bound check causes gcc failed to boostrap

2007-01-19 Thread mrs at apple dot com


--- Comment #3 from mrs at apple dot com  2007-01-19 22:02 ---
Testcase from delta, compile with:

$ ./xgcc -B./  t.c -O2 -S -Wall
t.c: In function 'gfc_get_namespace':
t.c:10: warning: array subscript is above array bounds


typedef struct { int kind; } gfc_typespec;
typedef struct gfc_namespace { gfc_typespec default_type[26]; } gfc_namespace;
void gfc_get_namespace ()
{
  gfc_namespace *ns=0;
  gfc_typespec *ts =0;
  int i;
  for (i = 'a'; i = 'z'; i++)
{
  ts = ns-default_type[i - 'a'];
  ts-kind = 0;
}
}


-- 


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



[Bug bootstrap/30511] False array bound check causes gcc failed to boostrap

2007-01-19 Thread pinskia at gcc dot gnu dot org


--- Comment #4 from pinskia at gcc dot gnu dot org  2007-01-19 22:05 ---
(In reply to comment #3)
 Testcase from delta, compile with:
Hmm, in the non reduced testcase, is default_type last?  Since in the reduced
testcase, default_type is last, it seems like we should not warn about that
case even if the bounds does go over anyways.


-- 


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



[Bug bootstrap/30511] False array bound check causes gcc failed to boostrap

2007-01-19 Thread mueller at gcc dot gnu dot org


--- Comment #5 from mueller at gcc dot gnu dot org  2007-01-19 22:15 ---
the ivopts problem is a duplicate of bug 26726.


-- 


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