This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/28439] Multiple evaluations of arithmetic if condition
- From: "steven at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 19 Jul 2006 23:08:13 -0000
- Subject: [Bug fortran/28439] Multiple evaluations of arithmetic if condition
- References: <bug-28439-12982@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #4 from steven at gcc dot gnu dot org 2006-07-19 23:08 -------
Andrew, you're wrong. :-P
My gfortran skills are not what they used to be, but I believe this is the fix:
Index: trans-stmt.c
===================================================================
--- trans-stmt.c (revision 115467)
+++ trans-stmt.c (working copy)
@@ -663,6 +663,7 @@ gfc_trans_arithmetic_if (gfc_code * code
/* Pre-evaluate COND. */
gfc_conv_expr_val (&se, code->expr);
+ se.expr = gfc_evaluate_now (se.expr, &se.pre);
/* Build something to compare with. */
zero = gfc_build_const (TREE_TYPE (se.expr), integer_zero_node);
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28439