https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106775
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jason at gcc dot gnu.org --- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> --- So, perhaps either we need to in the 556 if (swapped 557 && flag_strong_eval_order == 2 558 && (TREE_SIDE_EFFECTS (array_expr) || TREE_SIDE_EFFECTS (index_exp))) 559 expr = build_array_ref (input_location, index_exp, array_expr); 560 else 561 expr = build_array_ref (input_location, array_expr, index_exp); spot if array_expr has ARRAY_TYPE and is xvalue rather than lvalue choose some different representation which will ensure the side-effects are evaluated in the right order, perhaps by using save_expr around index_exp and using COMPOUND_EXPR for that save_expr and array_expr, or need to adjust lvalue_kind so that it is able to recognize even what we lower the array ref to in the line 559 case as array ref with ARRAY_TYPE xvalue base. We actually lower it as *(x + y) instead of x[y] with ensuring the side-effects being evaluated in the right order.