[Bug middle-end/59561] [4.9 Regression] warning: iteration 4 invokes undefined behavior

2014-01-31 Thread rguenth at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59561

Richard Biener  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #8 from Richard Biener  ---
Fixed as far as we care.


[Bug middle-end/59561] [4.9 Regression] warning: iteration 4 invokes undefined behavior

2014-01-24 Thread jakub at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59561

--- Comment #7 from Jakub Jelinek  ---
Author: jakub
Date: Fri Jan 24 23:17:25 2014
New Revision: 207065

URL: http://gcc.gnu.org/viewcvs?rev=207065&root=gcc&view=rev
Log:
PR middle-end/59561
* cfgloopmanip.c (copy_loop_info): If
loop->warned_aggressive_loop_optimizations, make sure
the flag is set in target loop too.

Modified:
trunk/gcc/ChangeLog
trunk/gcc/cfgloopmanip.c


[Bug middle-end/59561] [4.9 Regression] warning: iteration 4 invokes undefined behavior

2014-01-22 Thread jakub at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59561

--- Comment #6 from Jakub Jelinek  ---
(In reply to janus from comment #0)
> with -O2 and -O3, while 4.8 did not do that. Probably the warning is ok,
> since the test case is supposed to trigger a runtime error ("Index '5' of
> dimension 2 of array 'a' outside of expected range (4:1)").

Of course the warning is correct.
> 
> However, I see three possible problems:
> 1) The question is why it only happens with SAVE.

I get the warning also without SAVE.  Furthermore, the warning is not
guaranteed for all undefined behaviors in the loop of course, only if the loop
has known constant number of iterations, no early exits and is known to trigger
selected kinds of undefined behavior in some of the iterations.

> 2) I don't understand why the warning has 'iteration 4'. Shouldn't iteration
> 5 be the problem?

This is a middle-end warning, I don't see how the middle-end could find out
that the frontend wants to count the iterations differently.

> 3) The warning appears twice.

For that I have an untested fix:

2014-01-22  Jakub Jelinek  

PR middle-end/59561
* cfgloopmanip.c (copy_loop_info): If
loop->warned_aggressive_loop_optimizations, make sure
the flag is set in target loop too.

--- gcc/cfgloopmanip.c.jj2014-01-03 11:40:33.0 +0100
+++ gcc/cfgloopmanip.c2014-01-22 10:21:54.057871045 +0100
@@ -1022,6 +1022,8 @@ copy_loop_info (struct loop *loop, struc
   target->any_estimate = loop->any_estimate;
   target->nb_iterations_estimate = loop->nb_iterations_estimate;
   target->estimate_state = loop->estimate_state;
+  target->warned_aggressive_loop_optimizations
+|= loop->warned_aggressive_loop_optimizations;
 }

 /* Copies copy of LOOP as subloop of TARGET loop, placing newly


[Bug middle-end/59561] [4.9 Regression] warning: iteration 4 invokes undefined behavior

2014-01-17 Thread law at redhat dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59561

--- Comment #5 from Jeffrey A. Law  ---
Not a duplicate of 57904 AFAICT.


[Bug middle-end/59561] [4.9 Regression] warning: iteration 4 invokes undefined behavior

2013-12-20 Thread dominiq at lps dot ens.fr
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59561

Dominique d'Humieres  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org,
   ||law at redhat dot com
  Component|fortran |middle-end

--- Comment #4 from Dominique d'Humieres  ---
I think it is a middle-end issue.