public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100644] New: [11 regression] Deleted move constructor prevents templated constructor from being used
@ 2021-05-18  0:55 botond at mozilla dot com
  2021-05-18  6:21 ` [Bug c++/100644] [11/12 " rguenth at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: botond at mozilla dot com @ 2021-05-18  0:55 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100644
           Summary: [11 regression] Deleted move constructor prevents
                    templated constructor from being used
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: botond at mozilla dot com
  Target Milestone: ---

GCC 11 gives an error for the following code which GCC 10 and Clang accept:


struct NonMovable {
  NonMovable(NonMovable&&) = delete;
};

template <class T>
struct Maybe {
  NonMovable mMember;

  template <typename U>
  Maybe(Maybe<U>&&);
};

void foo(Maybe<int>);

void unlucky(Maybe<int>&& x) {
  Maybe<int> var{(Maybe<int>&&)x};
}


The error is:


main.cpp: In function ‘void unlucky(Maybe<int>&&)’:
main.cpp:16:33: error: use of deleted function
‘Maybe<int>::Maybe(Maybe<int>&&)’
   16 |   Maybe<int> var{(Maybe<int>&&)x};
      |                                 ^
main.cpp:6:8: note: ‘Maybe<int>::Maybe(Maybe<int>&&)’ is implicitly deleted
because the default definition would be ill-formed:
    6 | struct Maybe {
      |        ^~~~~
main.cpp:6:8: error: use of deleted function
‘NonMovable::NonMovable(NonMovable&&)’
main.cpp:2:3: note: declared here
    2 |   NonMovable(NonMovable &&) = delete;
      |   ^~~~~~~~~~


I believe the code should be accepted, with the deleted move constructor
ignored during overload resolution and the templated constructor used instead.

I explain my reasoning, with links to the standard, in more detail here:
https://bugzilla.mozilla.org/show_bug.cgi?id=1710235#c22

Please let me know if I've overlooked something and the code really is invalid.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-05-19 20:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-18  0:55 [Bug c++/100644] New: [11 regression] Deleted move constructor prevents templated constructor from being used botond at mozilla dot com
2021-05-18  6:21 ` [Bug c++/100644] [11/12 " rguenth at gcc dot gnu.org
2021-05-18  8:54 ` redi at gcc dot gnu.org
2021-05-18 15:57 ` jason at gcc dot gnu.org
2021-05-18 19:44 ` cvs-commit at gcc dot gnu.org
2021-05-18 21:19 ` cvs-commit at gcc dot gnu.org
2021-05-19 20:19 ` jason at gcc dot gnu.org

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).