From ed63cd2aa5b114565fe5499c3a6bf8da5e8e48ba Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 22 May 2024 18:41:27 -0400 Subject: c++: deleting array temporary [PR115187] Decaying the array temporary to a pointer and then deleting that crashes in verify_gimple_stmt, because the TARGET_EXPR is first evaluated inside the TRY_FINALLY_EXPR, but the cleanup point is outside. Fixed by using get_target_expr instead of save_expr. I also adjust the stabilize_expr comment to prevent me from again thinking it's a suitable replacement. PR c++/115187 gcc/cp/ChangeLog: * init.cc (build_delete): Use get_target_expr instead of save_expr. * tree.cc (stabilize_expr): Update comment. gcc/testsuite/ChangeLog: * g++.dg/cpp1z/array-prvalue3.C: New test. --- gcc/cp/tree.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'gcc/cp/tree.cc') diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc index 4d87661..0485a61 100644 --- a/gcc/cp/tree.cc +++ b/gcc/cp/tree.cc @@ -5924,7 +5924,11 @@ decl_storage_duration (tree decl) *INITP) an expression that will perform the pre-evaluation. The value returned by this function is a side-effect free expression equivalent to the pre-evaluated expression. Callers must ensure - that *INITP is evaluated before EXP. */ + that *INITP is evaluated before EXP. + + Note that if EXPR is a glvalue, the return value is a glvalue denoting the + same address; this function does not guard against modification of the + stored value like save_expr or get_target_expr do. */ tree stabilize_expr (tree exp, tree* initp) -- cgit v1.1