public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/96803] New: std::tuple chooses wrong constructor for uses-allocator construction
@ 2020-08-26 17:16 redi at gcc dot gnu.org
  2020-08-26 17:16 ` [Bug libstdc++/96803] " redi at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2020-08-26 17:16 UTC (permalink / raw)
  To: gcc-bugs

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.

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

end of thread, other threads:[~2020-09-22  9:41 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-26 17:16 [Bug libstdc++/96803] New: std::tuple chooses wrong constructor for uses-allocator construction redi at gcc dot gnu.org
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

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