https://gcc.gnu.org/g:628aecb050bbbc4bb0bd4468c474623e20d64e21

commit r15-9501-g628aecb050bbbc4bb0bd4468c474623e20d64e21
Author: Jason Merrill <ja...@redhat.com>
Date:   Tue Apr 15 11:23:57 2025 -0400

    c++: constexpr, trivial, and non-alias target [PR111075]
    
    On Darwin and other targets with !can_alias_cdtor, we instead go to
    maybe_thunk_ctor, which builds a thunk function that calls the general
    constructor.  And then cp_fold tries to constant-evaluate that call, and we
    ICE because we don't expect to ever be asked to constant-evaluate a call to
    a trivial function.
    
    No new test because this fixes g++.dg/torture/tail-padding1.C on affected
    targets.
    
            PR c++/111075
    
    gcc/cp/ChangeLog:
    
            * constexpr.cc (cxx_eval_call_expression): Allow trivial
            call from a thunk.

Diff:
---
 gcc/cp/constexpr.cc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc
index dc59f59aa3f3..4346b29abc68 100644
--- a/gcc/cp/constexpr.cc
+++ b/gcc/cp/constexpr.cc
@@ -3103,6 +3103,9 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree 
t,
      we can only get a trivial function here with -fno-elide-constructors.  */
   gcc_checking_assert (!trivial_fn_p (fun)
                       || !flag_elide_constructors
+                      /* Or it's a call from maybe_thunk_body (111075).  */
+                      || (TREE_CODE (t) == CALL_EXPR ? CALL_FROM_THUNK_P (t)
+                          : AGGR_INIT_FROM_THUNK_P (t))
                       /* We don't elide constructors when processing
                          a noexcept-expression.  */
                       || cp_noexcept_operand);

Reply via email to