https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99859
--- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> --- So perhaps --- gcc/cp/constexpr.c.jj 2021-03-19 18:36:49.165304923 +0100 +++ gcc/cp/constexpr.c 2021-04-07 15:33:31.993242067 +0200 @@ -1616,6 +1616,22 @@ cxx_bind_parameters_in_call (const const /* The destructor needs to see any modifications the callee makes to the argument. */ *non_constant_args = true; + else + { + tree addr = arg; + STRIP_NOPS (addr); + /* When a method or function is called with address of a heap + allocated variable, don't cache it so that any modifications + in it are performed. */ + if (TREE_CODE (addr) == ADDR_EXPR) + if (tree var = get_base_address (TREE_OPERAND (addr, 0))) + if (VAR_P (var) + && (DECL_NAME (var) == heap_uninit_identifier + || DECL_NAME (var) == heap_identifier + || DECL_NAME (var) == heap_vec_uninit_identifier + || DECL_NAME (var) == heap_vec_identifier)) + *non_constant_args = true; + } /* For virtual calls, adjust the this argument, so that it is the object on which the method is called, rather than for the heap vars and something similar for the global var ctors?