This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: basic VRP min/max range overflow question


Robert Dewar wrote:
> Yes, absolutely, a compiler should generate warnings as much as possible when
> it is making these kind of assujmptions.

Then, you will like the following kind of patches:

Index: tree-data-ref.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-data-ref.c,v
retrieving revision 2.32
diff -d -u -p -r2.32 tree-data-ref.c
--- tree-data-ref.c	8 Jun 2005 08:47:01 -0000	2.32
+++ tree-data-ref.c	20 Jun 2005 12:57:21 -0000
@@ -499,6 +499,8 @@ estimate_niter_from_size_of_data (struct
 				 fold (build2 (MINUS_EXPR, integer_type_node, 
 					       data_size, init)), step));
 
+      warning (0, "%H undefined behavior if loop runs for more than %qE iterations",
+	       find_loop_location (loop), estimation);
       record_estimate (loop, estimation, boolean_true_node, stmt);
     }
 }

This is the best the compiler can do: it has warned the user of a
possible undefined behavior in the code, and that it will use this
assumption for transforming the code.

The other opportunity raised in this thread for inferring loop bounds
from undefined behavior of overflowing signed induction variables is
still not implemented.  I will propose a patch with the corresponding
warning messages.

Sebastian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]