------- Comment #12 from jakub at gcc dot gnu dot org 2007-11-28 13:20 ------- So, shouldn't the expression_without_side_effects_p routine just be renamed to expression_could_trap_p, otherwise it will be confused again and again with !TREE_SIDE_EFFECTS on the expr? The gimplify_cond_expr new hunk then could be + if (gimplify_ctxp->allow_rhs_cond_expr + /* If either branch has side effects or could trap, it can't be + evaluated unconditionally. */ + && !TREE_SIDE_EFFECTS (TREE_OPERAND (*expr_p, 1)) + && !expression_could_trap_p (TREE_OPERAND (*expr_p, 1)) + && !TREE_SIDE_EFFECTS (TREE_OPERAND (*expr_p, 2)) + && !expression_could_trap_p (TREE_OPERAND (*expr_p, 2))) + return gimplify_pure_cond_expr (expr_p, pre_p);
This would allow side effects on condition of the COND_EXPR, and at least to me would be less confusing (and given that Diego raised that question first, I'm probably not alone). -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34005