public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "Joost.VandeVondele at mat dot ethz.ch" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/58746] New: Incorrect warning with -Waggressive-loop-optimizations Date: Wed, 16 Oct 2013 12:45:00 -0000 [thread overview] Message-ID: <bug-58746-4@http.gcc.gnu.org/bugzilla/> (raw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58746 Bug ID: 58746 Summary: Incorrect warning with -Waggressive-loop-optimizations Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: Joost.VandeVondele at mat dot ethz.ch Only when compiled with LTO, the following testcase yields: gfortran -flto=jobserver -use-linker-plugin -O2 -g -ffree-form test.f90 test.f90: In function ‘expint.constprop’: test.f90:43:0: warning: iteration 2147483646 invokes undefined behavior [-Waggressive-loop-optimizations] DO ii=1,nm1 ^ test.f90:43:0: note: containing loop However, nm1 is clearly 0, by inspection of the code and as the write statement at runtime illustrates: nm1= 0 > cat test.f90 MODULE mathlib IMPLICIT NONE INTEGER, PARAMETER :: dp = SELECTED_REAL_KIND ( 14, 200 ) INTEGER, PARAMETER :: maxfac = 30 REAL(KIND=dp), PARAMETER, DIMENSION (0:maxfac) :: fac = 1 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'mathlib' CONTAINS FUNCTION expint(n,x) INTEGER :: n REAL(dp) :: x, expint CHARACTER(len=*), PARAMETER :: routineN = 'expint', & routineP = moduleN//':'//routineN INTEGER, PARAMETER :: maxit = 100 REAL(dp), PARAMETER :: eps = 6.e-14_dp, & euler = 0.5772156649015328606065120_dp, fpmin = TINY(0.0_dp) INTEGER :: i, ii, nm1 REAL(dp) :: del, fact, h, psi nm1=n-1 write(6,*) "nm1=",nm1 expint=-LOG(x)-euler fact=1.0_dp DO i=1,MAXIT fact=-fact*x/i IF(i.NE.nm1) THEN del=-fact/(i-nm1) ELSE psi=-euler DO ii=1,nm1 psi=psi+1.0_dp/ii END DO del=fact*(-LOG(x)+psi) END IF expint=expint+del IF(ABS(del).LT.ABS(expint)*EPS) RETURN END DO END FUNCTION expint END MODULE USE mathlib REAL(KIND=dp), VOLATILE :: r=0.1_dp r = expint(1,r) END >From gcc-bugs-return-431932-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Wed Oct 16 12:48:54 2013 Return-Path: <gcc-bugs-return-431932-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org> Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 1671 invoked by alias); 16 Oct 2013 12:48:54 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: <gcc-bugs.gcc.gnu.org> List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/> List-Post: <mailto:gcc-bugs@gcc.gnu.org> List-Help: <mailto:gcc-bugs-help@gcc.gnu.org> Sender: gcc-bugs-owner@gcc.gnu.org Delivered-To: mailing list gcc-bugs@gcc.gnu.org Received: (qmail 1287 invoked by uid 48); 16 Oct 2013 12:48:50 -0000 From: "rian.gabriel at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/58747] New: new_for Date: Wed, 16 Oct 2013 12:48:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 4.8.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: critical X-Bugzilla-Who: rian.gabriel at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: <bug-58747-4@http.gcc.gnu.org/bugzilla/> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-10/txt/msg01076.txt.bz2 Content-length: 488 http://gcc.gnu.org/bugzilla/show_bug.cgi?idX747 Bug ID: 58747 Summary: new_for Product: gcc Version: 4.8.1 Status: UNCONFIRMED Severity: critical Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: rian.gabriel at gmail dot com Sorry if it has already been reported. The code compiles and runs without warning. int i = 0; for(int i : v) { ... }
next reply other threads:[~2013-10-16 12:45 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-10-16 12:45 Joost.VandeVondele at mat dot ethz.ch [this message] 2013-11-27 8:56 ` [Bug middle-end/58746] [4.9 Regression] " Joost.VandeVondele at mat dot ethz.ch 2013-11-27 9:07 ` Joost.VandeVondele at mat dot ethz.ch 2013-12-19 15:20 ` rguenth at gcc dot gnu.org 2013-12-19 15:32 ` rguenth at gcc dot gnu.org 2013-12-20 6:49 ` dominiq at lps dot ens.fr 2013-12-20 21:56 ` dominiq at lps dot ens.fr 2014-01-17 17:51 ` law at redhat dot com
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-58746-4@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).