[Bug c++/91974] function not sequenced before function argument
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91974 --- Comment #11 from Jakub Jelinek --- Author: jakub Date: Thu Nov 21 17:12:57 2019 New Revision: 278577 URL: https://gcc.gnu.org/viewcvs?rev=278577=gcc=rev Log: Backported from mainline 2019-10-04 Jakub Jelinek PR c++/91974 * cp-gimplify.c (cp_gimplify_expr) : For -fstrong-eval-order ensure CALL_EXPR_FN side-effects are evaluated before any arguments. Additionally, ensure CALL_EXPR_FN that isn't invariant nor OBJ_TYPE_REF nor SSA_NAME is forced into a temporary. * g++.dg/cpp1z/eval-order5.C: New test. Added: branches/gcc-8-branch/gcc/testsuite/g++.dg/cpp1z/eval-order5.C Modified: branches/gcc-8-branch/gcc/cp/ChangeLog branches/gcc-8-branch/gcc/cp/cp-gimplify.c branches/gcc-8-branch/gcc/testsuite/ChangeLog
[Bug c++/91974] function not sequenced before function argument
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91974 --- Comment #10 from Jakub Jelinek --- The originally reported issue fixed for 9.3+ too. Not really sure if it is a good idea to backport the shift and array ref changes, those are quite invasive.
[Bug c++/91974] function not sequenced before function argument
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91974 --- Comment #9 from Jakub Jelinek --- Author: jakub Date: Mon Oct 21 11:47:09 2019 New Revision: 277256 URL: https://gcc.gnu.org/viewcvs?rev=277256=gcc=rev Log: Backported from mainline 2019-10-04 Jakub Jelinek PR c++/91974 * cp-gimplify.c (cp_gimplify_expr) : For -fstrong-eval-order ensure CALL_EXPR_FN side-effects are evaluated before any arguments. Additionally, ensure CALL_EXPR_FN that isn't invariant nor OBJ_TYPE_REF nor SSA_NAME is forced into a temporary. * g++.dg/cpp1z/eval-order5.C: New test. Added: branches/gcc-9-branch/gcc/testsuite/g++.dg/cpp1z/eval-order5.C Modified: branches/gcc-9-branch/gcc/cp/ChangeLog branches/gcc-9-branch/gcc/cp/cp-gimplify.c branches/gcc-9-branch/gcc/testsuite/ChangeLog
[Bug c++/91974] function not sequenced before function argument
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91974 Richard Biener changed: What|Removed |Added Known to work||10.0 --- Comment #8 from Richard Biener --- Fixed on trunk (sofar?)
[Bug c++/91974] function not sequenced before function argument
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91974 --- Comment #7 from Jakub Jelinek --- Author: jakub Date: Fri Oct 4 06:54:05 2019 New Revision: 276562 URL: https://gcc.gnu.org/viewcvs?rev=276562=gcc=rev Log: PR c++/91974 * cp-gimplify.c (cp_gimplify_expr) : For -fstrong-eval-order ensure CALL_EXPR_FN side-effects are evaluated before any arguments. Additionally, ensure CALL_EXPR_FN that isn't invariant nor OBJ_TYPE_REF nor SSA_NAME is forced into a temporary. * g++.dg/cpp1z/eval-order5.C: New test. Added: trunk/gcc/testsuite/g++.dg/cpp1z/eval-order5.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/cp-gimplify.c trunk/gcc/testsuite/ChangeLog
[Bug c++/91974] function not sequenced before function argument
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91974 Jakub Jelinek changed: What|Removed |Added Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org --- Comment #6 from Jakub Jelinek --- Created attachment 46992 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46992=edit gcc10-pr91974.patch The above patch broke a couple of devirtualization etc. testcases, this version should fix that. Untested so far except for the tests that FAILed with the previous patch.
[Bug c++/91974] function not sequenced before function argument
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91974 Jakub Jelinek changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2019-10-02 CC||jakub at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #5 from Jakub Jelinek --- I think we need something like: --- gcc/cp/cp-gimplify.c.jj 2019-09-27 22:13:18.365903348 +0200 +++ gcc/cp/cp-gimplify.c2019-10-02 22:42:41.878588998 +0200 @@ -818,6 +818,20 @@ cp_gimplify_expr (tree *expr_p, gimple_s case CALL_EXPR: ret = GS_OK; + if (flag_strong_eval_order == 2 + && CALL_EXPR_FN (*expr_p) + && cp_get_callee_fndecl_nofold (*expr_p) == NULL_TREE) + { + enum gimplify_status t + = gimplify_expr (_EXPR_FN (*expr_p), pre_p, NULL, +is_gimple_call_addr, fb_rvalue); + if (t == GS_ERROR) + ret = GS_ERROR; + else if (TREE_CODE (CALL_EXPR_FN (*expr_p)) != SSA_NAME) + CALL_EXPR_FN (*expr_p) + = get_initialized_tmp_var (CALL_EXPR_FN (*expr_p), pre_p, +NULL); + } if (!CALL_EXPR_FN (*expr_p)) /* Internal function call. */; else if (CALL_EXPR_REVERSE_ARGS (*expr_p))
[Bug c++/91974] function not sequenced before function argument
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91974 --- Comment #4 from Barry Revzin --- Yes, sorry if that wasn't clear, this is with -std=c++17.
[Bug c++/91974] function not sequenced before function argument
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91974 --- Comment #3 from Andrew Pinski --- Just to make sure, you are using -std=c++17 or -std=gnu++17 (or -fstrong-eval-order)? Because it is not obvious from this report.
[Bug c++/91974] function not sequenced before function argument
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91974 --- Comment #2 from Barry Revzin --- C++17 does change this rule. expr.call/8: The postfix-expression is sequenced before each expression in the expression-list and any default argument. The initialization of a parameter, including every associated value computation and side effect, is indeterminately sequenced with respect to that of any other parameter.
[Bug c++/91974] function not sequenced before function argument
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91974 --- Comment #1 from Andrew Pinski --- I dont think this is well defined. A call and its arguments are not sequence points. Yes there is a sequence point between the assignment and 0 but nothing else. Note c++17 does change the rules and I have not read them yet.