[Bug libstdc++/124982] New: std::pair and std::tuple move assignment with non-move-assignable types

aoliva at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Apr 22 09:52:56 GMT 2026


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

            Bug ID: 124982
           Summary: std::pair and std::tuple move assignment with
                    non-move-assignable types
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: aoliva at gcc dot gnu.org
  Target Milestone: ---

Analogously to bug 71301, I'd expect the following to not compile because T is
not move-assignable, but we quietly use copy assignments instead.

// { dg-do compile { target c++11 } }

#include <tuple>
#include <utility>

struct T {
  T& operator=(T const&) = default;
  T& operator=(T&&) = delete;
};

#if ASSERTS
static_assert(!std::is_nothrow_move_assignable<T>::value);
static_assert(!std::is_move_assignable<std::tuple<T> >::value);
static_assert(!std::is_move_assignable<std::pair<T, T> >::value);
#endif

void t() {
  std::tuple<T> x, y;

  y = std::move (x);
}

void p() {
  std::pair<T, T> x, y;

  y = std::move (x);
}

#if DIRECT
void d() {
  T x, y;

  y = std::move (x);
}
#endif


More information about the Gcc-bugs mailing list