public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/94062] Cannot construct tuple from convertible types
Date: Thu, 19 Mar 2020 11:30:32 +0000	[thread overview]
Message-ID: <bug-94062-4-Nwcaq4Qrli@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-94062-4@http.gcc.gnu.org/bugzilla/>

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.

  parent reply	other threads:[~2020-03-19 11:30 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-94062-4@http.gcc.gnu.org/bugzilla/>
2020-03-19  9:46 ` [Bug libstdc++/94062] " m.cencora at gmail dot com
2020-03-19 10:43 ` redi at gcc dot gnu.org
2020-03-19 10:49 ` redi at gcc dot gnu.org
2020-03-19 10:57 ` m.cencora at gmail dot com
2020-03-19 11:30 ` redi at gcc dot gnu.org [this message]
2020-03-19 12:04 ` [Bug c++/94062] " redi at gcc dot gnu.org
2020-03-19 12:12 ` m.cencora at gmail dot com
2020-03-19 12:38 ` redi at gcc dot gnu.org
2020-03-19 12:42 ` m.cencora at gmail dot com
2020-03-19 14:18 ` redi at gcc dot gnu.org
2020-08-17 10:23 ` redi at gcc dot gnu.org
2020-08-17 12:02 ` m.cencora at gmail dot com
2020-08-17 12:51 ` redi at gcc dot gnu.org
2020-08-17 13:40 ` m.cencora at gmail dot com
2020-08-17 13:58 ` redi at gcc dot gnu.org
2020-08-17 14:29 ` cvs-commit at gcc dot gnu.org
2020-08-17 14:51 ` m.cencora at gmail dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-94062-4-Nwcaq4Qrli@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).