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

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

https://gcc.gnu.org/g:ac45382d0c06bc1a90ce74e0379e52496ab3bffe

commit r16-5370-gac45382d0c06bc1a90ce74e0379e52496ab3bffe
Author: Tomasz KamiÅski <[email protected]>
Date:   Fri Oct 24 16:45:59 2025 +0200

    libstdc++: Fix construction function_ref from nontype<&S::x> and
reference_wrapper [PR121858]

    To reduce instantiation count, function_ref(nontype<&S::x>, r) previously
    reused the invoker from function_ref(nontype<&S::x>, &r). This assumed r
was
    always a reference to S or a derived class. However, this constructor is
also
    valid for lvalues (but not rvalues) of reference_wrapper specializations.

    This patch fixes this by limiting above optimization only to situations,
    when argument is not specialization of reference_wrapper. This is achieved
    bu comparing __inv_unwrap<_Td>::type with _Td. We use __inv_unwrap because
    unwrap_reference_t does not handle cv-qualified types.

            PR libstdc++/121858

    libstdc++-v3/ChangeLog:

            * include/bits/funcref_impl.h
            (function_ref::function_ref(nontype<__fn>, _Up&&)): Handle.
            reference_wrapper.
            * testsuite/20_util/function_ref/call.cc: Call and update
            test05(). Add new test06() for reference_wrapper.

    Reviewed-by: Jonathan Wakely <[email protected]>
    Signed-off-by: Tomasz KamiÅski <[email protected]>

Reply via email to