https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124425

--- Comment #8 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <[email protected]>:

https://gcc.gnu.org/g:2ba14bb40f2b32d6f4d88e3e6d9c16c22faef605

commit r16-8027-g2ba14bb40f2b32d6f4d88e3e6d9c16c22faef605
Author: Jakub Jelinek <[email protected]>
Date:   Thu Mar 12 08:48:47 2026 +0100

    c++: Support proxy iterators in reflection get_range_elts [PR124425]

    I've punted up on proxy iterators because I didn't know how to construct
    a test for those.

    The following patch adds support for thosse.  Besides converting those
    to valuet if needed and for classes making sure they live in a TARGET_EXPR
    where they can be subsequently destructed, the patch adds
    CLEANUP_POINT_EXPRs around the deref and inc expressions such that the
    TARGET_EXPRs in those expressions are immediately destructed after
returning
    what we need.
    cmp doesn't need that because
      cmp = condition_conversion (cmp);
    already adds that.
    Without the CLEANUP_POINT_EXPRs stuff is destructed (and marked as if out
of
    lifetime) only in some CLEANUP_POINT_EXPR surrounding the metafn call,
which
    is certainly too late for stuff that is reentered and left again in every
    iteration.
    I wrongly thought I'd need to duplicate the first part of
CLEANUP_POINT_EXPR
    handling in reflect.cc (which is complicated because struct constexpr_ctx
    is only defined in constexpr.cc), then cxx_eval_constant_expression
    e.g. deref and then duplicate the second part of CLEANUP_POINT_EXPR
    handling, but it seems that the CLEANUP_POINT_EXPR evaluation just returns
    what was returned from the recursive call on its operand, which is I think
    exactly what we need.

    This change broke 2 testcases, reflect_constant_array4.C and
    define_static_array4.C, but IMHO correctly so, apparently what I had
    there was creating std::pair<const int &, const int &> with references
    to something that should have been immediately destructed in each
iteration.
    So, the patch fixes those tests to use std::pair<int, int> instead.

    2026-03-12  Jakub Jelinek  <[email protected]>

            PR c++/124425
            * reflect.cc (get_range_elts): Handle proxy iterators.  Call
            fold_build_cleanup_point_expr on both deref and inc.

            * g++.dg/reflect/define_static_array4.C: Enable commented out
            static_asserts and fix up the first one.
            (as_pair): Make sure to return std::pair <int, int>.
            * g++.dg/reflect/reflect_constant_array4.C: Enable commented out
            static_asserts and fix up the first one.
            (as_pair): Make sure to return std::pair <int, int>.
            * g++.dg/reflect/reflect_constant_array7.C: New test.
            * g++.dg/reflect/reflect_constant_array8.C: New test.
  • [Bug c++/124425] [reflection] U... cvs-commit at gcc dot gnu.org via Gcc-bugs

Reply via email to