On Apr 9, 2022, Jason Merrill <ja...@redhat.com> wrote: >> goto <D.4489>; >> (void) S::~S (&((struct T *) this)->D.4458)
>> Now, ISTM that the goto target selected for the return stmt bypasses the >> subobject dtor call and the full-object clobber. That sounds like >> another bug, no? > The subobject cleanup and clobber should be evaluated along the way, > the evaluation of CLEANUP_EXPR isn't affected by jump_target. *nod*, I was just confused by the dump, that made the CLEANUP_EXPR seem part of the STATEMENT_LIST. > I think the only thing we're wrongly skipping is the actual return, > and your patch works around that. I think that makes sense for now; I > have a patch for GCC 13 to remove cdtor_label entirely. Ah, great, thanks. > Your patch is OK. Here's the adjusted (subject, thanks) patch I'm about to install. c++: Tolerate cdtors returning this in constexpr On targets that return this from cdtors, cxx_eval_call_expression may flag flowing off the end of a dtor. That's preempted for ctors, and avoided entirely when dtors return void, but when they return this, the return value should be conceptually disregarded, without making room for such internal ABI details to make a program ill-formed, as in g++.dg/cpp2a/constexpr-dtor12.C on arm-eabi. for gcc/cp/ChangeLog * constexpr.cc (cxx_eval_call_expression): Disregard dtor result. --- gcc/cp/constexpr.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc index 9c40b0515747d..d8bc864ae6bcc 100644 --- a/gcc/cp/constexpr.cc +++ b/gcc/cp/constexpr.cc @@ -2889,7 +2889,8 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t, else { result = *ctx->global->values.get (res); - if (result == NULL_TREE && !*non_constant_p) + if (result == NULL_TREE && !*non_constant_p + && !DECL_DESTRUCTOR_P (fun)) { if (!ctx->quiet) error ("%<constexpr%> call flows off the end " -- Alexandre Oliva, happy hacker https://FSFLA.org/blogs/lxo/ Free Software Activist GNU Toolchain Engineer Disinformation flourishes because many people care deeply about injustice but very few check the facts. Ask me about <https://stallmansupport.org>