This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] Warn on undefined loop exit
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Richard Biener <richard dot guenther at gmail dot com>
- Cc: Andrew Stubbs <ams at codesourcery dot com>, Marek Polacek <polacek at redhat dot com>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 18 Feb 2015 15:05:51 +0100
- Subject: Re: [patch] Warn on undefined loop exit
- Authentication-results: sourceware.org; auth=none
- References: <545A9A86 dot 1070008 at codesourcery dot com> <CAFiYyc3PLqikcS6DzTP0DLOxApYqsaYMvCGiP3O_rbdrPsAPPw at mail dot gmail dot com> <54652425 dot 9070104 at codesourcery dot com> <546CC62B dot 1010109 at codesourcery dot com> <20141119163938 dot GE29446 at redhat dot com> <546CFB3C dot 5030307 at codesourcery dot com> <CAFiYyc1_U5q+nSdQxRkeHMzADq52RdDo-U4LkxBK-2MhHGdbSg at mail dot gmail dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Thu, Nov 20, 2014 at 05:27:35PM +0100, Richard Biener wrote:
> On Wed, Nov 19, 2014 at 9:19 PM, Andrew Stubbs <ams@codesourcery.com> wrote:
> > On 19/11/14 16:39, Marek Polacek wrote:
> >>
> >> On Wed, Nov 19, 2014 at 04:32:43PM +0000, Andrew Stubbs wrote:
> >>>
> >>> + if (warning_at (gimple_location (elt->stmt),
> >>> + OPT_Waggressive_loop_optimizations,
> >>> + "Loop exit may only be reached after
> >>> undefined behaviour."))
> >>
> >>
> >> Warnings should start with a lowercase and should be without
> >> a fullstop at the end.
> >
> >
> > Fixed, and I spotted a britishism too.
>
> If it's really duplicated code can you split it out to a function?
>
> + if (OPT_Waggressive_loop_optimizations)
> + {
>
> this doesn't do what you think it does ;) The variable to check is
> warn_aggressive_loop_optimizations.
>
> + if (exit_warned && problem_stmts != vNULL)
> + {
>
> !problem_stmts.empty ()
>
> Otherwise it looks ok.
This caused PR64491. If the loop has multiple exits, the loop might be
exit earlier and so it would be just fine if the other loop exit may only be
reached after undefined behavior.
Jakub