On Sat, Jun 16, 2018 at 12:43:08PM -0700, Steve Kargl wrote: > > This is a different answer than what you gave in > the PR when I asked if you were special casing > .and. and .or. It is trivial to force the evaluation > of operands. I already posted the diff in the PR > where I special cased .and. and .or. > > op1 .op. op2 > > needs to be converted to > > tmp1 = op1 > tmp2 = op2 > x = tmp1 .op. tmp > > for all binary operators. >
Untested. Index: trans-expr.c =================================================================== --- trans-expr.c (revision 261674) +++ trans-expr.c (working copy) @@ -3429,6 +3429,10 @@ gfc_conv_expr_op (gfc_se * se, gfc_expr * expr) gfc_conv_expr (&rse, expr->value.op.op2); gfc_add_block_to_block (&se->pre, &rse.pre); + /* Force evaluation of op1 and op2 to prevent shorting-circuiting. */ + lse.expr = gfc_evaluate_now (lse.expr); + rse.expr = gfc_evaluate_noe (rse.expr); + if (checkstring) { gfc_conv_string_parameter (&lse); -- Steve