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

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

https://gcc.gnu.org/g:46cfa36e295943d4bfa01c033a17f48c70154eeb

commit r15-10284-g46cfa36e295943d4bfa01c033a17f48c70154eeb
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