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 libstdc++/96803] New: std::tuple chooses wrong constructor for uses-allocator construction
Date: Wed, 26 Aug 2020 17:16:46 +0000	[thread overview]
Message-ID: <bug-96803-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 96803
           Summary: std::tuple chooses wrong constructor for
                    uses-allocator construction
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

#include <tuple>
#include <memory>

struct X
{
  using allocator_type = std::allocator<int>;

  X(X&&) { }
  X(std::allocator_arg_t, const allocator_type&, X&&) { }

  explicit X(int) { }
  explicit X(int, allocator_type) { }
};

int main()
{
  std::tuple<int> o(0);
  std::tuple<X> ok(o);
  std::tuple<X> nok(std::allocator_arg, std::allocator<int>(), o);
}

The last line of main fails:

In file included from tup.C:1:
/home/jwakely/gcc/10/include/c++/10.2.1/tuple: In instantiation of
'std::_Head_base<_Idx, _Head, true>::_Head_base(std::__uses_alloc1<_Alloc>,
_UHead&&) [with _Alloc = std::allocator<int>; _UHead = const int&; long
unsigned int _Idx = 0; _Head = X]':
/home/jwakely/gcc/10/include/c++/10.2.1/tuple:421:43:   required from
'std::_Tuple_impl<_Idx, _Head>::_Tuple_impl(std::allocator_arg_t, const
_Alloc&, const std::_Tuple_impl<_Idx, _UHead>&) [with _Alloc =
std::allocator<int>; _UHead = int; long unsigned int _Idx = 0; _Head = X]'
/home/jwakely/gcc/10/include/c++/10.2.1/tuple:775:70:   required from
'std::tuple<_Elements>::tuple(std::allocator_arg_t, const _Alloc&, const
std::tuple<_Args2 ...>&) [with _Alloc = std::allocator<int>; _UElements =
{int}; bool _Valid = true; typename
std::enable_if<std::tuple<_Elements>::_TCC<_Valid>::__is_explicitly_constructible<const
_UElements& ...>(), bool>::type <anonymous> = false; _Elements = {X}]'
tup.C:19:65:   required from here
/home/jwakely/gcc/10/include/c++/10.2.1/tuple:110:65: error: no matching
function for call to 'X::X(const std::allocator_arg_t&, const
std::allocator<int>&, const int&)'
  110 |  : _Head(allocator_arg, *__a._M_a, std::forward<_UHead>(__uhead)) { }
      |                                                                 ^
tup.C:12:12: note: candidate: 'X::X(int, X::allocator_type)'
   12 |   explicit X(int, allocator_type) { }
      |            ^
tup.C:12:12: note:   candidate expects 2 arguments, 3 provided
tup.C:11:12: note: candidate: 'X::X(int)'
   11 |   explicit X(int) { }
      |            ^
tup.C:11:12: note:   candidate expects 1 argument, 3 provided
tup.C:9:3: note: candidate: 'X::X(std::allocator_arg_t, const allocator_type&,
X&&)'
    9 |   X(std::allocator_arg_t, const allocator_type&, X&&) { }
      |   ^
tup.C:9:50: note:   no known conversion for argument 3 from 'const int' to
'X&&'
    9 |   X(std::allocator_arg_t, const allocator_type&, X&&) { }
      |                                                  ^~~
tup.C:8:3: note: candidate: 'X::X(X&&)'
    8 |   X(X&&) { }
      |   ^
tup.C:8:3: note:   candidate expects 1 argument, 3 provided


The problem is that the __use_alloc call in _Tuple_impl uses the wrong type.

             reply	other threads:[~2020-08-26 17:16 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-26 17:16 redi at gcc dot gnu.org [this message]
2020-08-26 17:16 ` [Bug libstdc++/96803] " redi at gcc dot gnu.org
2020-08-26 18:30 ` redi at gcc dot gnu.org
2020-08-26 18:33 ` cvs-commit at gcc dot gnu.org
2020-09-22  6:47 ` cvs-commit at gcc dot gnu.org
2020-09-22  6:48 ` cvs-commit at gcc dot gnu.org
2020-09-22  7:42 ` cvs-commit at gcc dot gnu.org
2020-09-22  9:40 ` cvs-commit at gcc dot gnu.org
2020-09-22  9:40 ` cvs-commit at gcc dot gnu.org
2020-09-22  9:41 ` cvs-commit at gcc dot gnu.org
2020-09-22  9:41 ` redi at gcc dot gnu.org

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-96803-4@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).