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

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

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

commit r16-3541-gc8a24f60b6874fca4fb3adb153f8d5f1dd72b951
Author: Jonathan Wakely <[email protected]>
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 <[email protected]>

Reply via email to