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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|libstdc++                   |c++

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Reduced to remove any libstdc++ code:

template<typename T> T&& forward(T& t) { return static_cast<T&&>(t); }

template<typename T>
  struct tuple : T
  {
    template<typename U>
      tuple(U&& u)
      : T(forward<U>(u))
      { }
  };

struct Bar1
{
    Bar1(const Bar1&) = delete;
    Bar1(Bar1&&) = delete;
};

struct Foo1
{
    operator Bar1() const;
};

int main()
{
  tuple<Bar1> t{ Foo1{} };
}

With -std=c++17:

94062.cc: In instantiation of 'tuple<T>::tuple(U&&) [with U = Foo1; T = Bar1]':
94062.cc:25:25:   required from here
94062.cc:8:24: error: use of deleted function 'Bar1::Bar1(Bar1&&)'
    8 |       : T(forward<U>(u))
      |                        ^
94062.cc:15:5: note: declared here
   15 |     Bar1(Bar1&&) = delete;
      |     ^~~~


EDG also rejects it:

"94062.cc", line 8: error: function "Bar1::Bar1(Bar1 &&)" (declared at line 15)
          cannot be referenced -- it is a deleted function
        : T(forward<U>(u))
           ^
          detected during instantiation of "tuple<T>::tuple(U &&) [with T=Bar1,
                    U=Foo1]" at line 25

1 error detected in the compilation of "94062.cc".


But MSVC and Clang compile it in C++17 mode.

Reply via email to