public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/59561] [4.9 Regression] warning: iteration 4 invokes undefined behavior Date: Wed, 22 Jan 2014 09:36:00 -0000 [thread overview] Message-ID: <bug-59561-4-JAX8apnqrl@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-59561-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59561 --- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> --- (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 <jakub@redhat.com> 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.jj 2014-01-03 11:40:33.000000000 +0100 +++ gcc/cfgloopmanip.c 2014-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
next prev parent reply other threads:[~2014-01-22 9:36 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-12-19 13:38 [Bug fortran/59561] New: " janus at gcc dot gnu.org 2013-12-19 15:21 ` [Bug fortran/59561] " rguenth at gcc dot gnu.org 2013-12-20 17:08 ` janus at gcc dot gnu.org 2013-12-20 22:04 ` dominiq at lps dot ens.fr 2013-12-20 22:07 ` [Bug middle-end/59561] " dominiq at lps dot ens.fr 2014-01-17 19:42 ` law at redhat dot com 2014-01-22 9:36 ` jakub at gcc dot gnu.org [this message] 2014-01-24 23:18 ` jakub at gcc dot gnu.org 2014-01-31 11:20 ` rguenth at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-59561-4-JAX8apnqrl@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).