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

--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-14 branch has been updated by Jonathan Wakely
<r...@gcc.gnu.org>:

https://gcc.gnu.org/g:72c9a10d700e5f4297aed523a79b0d7dc633f14e

commit r14-12000-g72c9a10d700e5f4297aed523a79b0d7dc633f14e
Author: Jonathan Wakely <jwak...@redhat.com>
Date:   Mon Sep 1 18:12:27 2025 +0100

    libstdc++: Fix std::get<T> for std::pair with reference members [PR121745]

    Make the std::get<T> overloads for rvalues use std::forward<T>(p.first)
    not std::move(p.first), so that lvalue reference members are not
    incorrectly converted to rvalues.

    It might appear that std::move(p).first would also work, but the
    language rules say that for std::pair<T&&, U> that would produce T&
    rather than the expected T&& (see the discussion in P2445R1 §8.2).

    Additional tests are added to verify all combinations of reference
    members, value categories, and const-qualification.

    libstdc++-v3/ChangeLog:

            PR libstdc++/121745
            * include/bits/stl_pair.h (get): Use forward instead of move in
            std::get<T> overloads for rvalue pairs.
            * testsuite/20_util/pair/astuple/get_by_type.cc: Check all value
            categories and cv-qualification.

    Reviewed-by: Tomasz KamiÅski <tkami...@redhat.com>
    (cherry picked from commit c8a24f60b6874fca4fb3adb153f8d5f1dd72b951)

Reply via email to