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
* [Bug libstdc++/96803] std::tuple chooses wrong constructor for uses-allocator construction
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 ` redi at gcc dot gnu.org
2020-08-26 18:30 ` redi at gcc dot gnu.org
` (8 subsequent siblings)
9 siblings, 0 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
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2020-08-26
Assignee|unassigned at gcc dot gnu.org |redi at gcc dot gnu.org
Ever confirmed|0 |1
Status|UNCONFIRMED |ASSIGNED
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libstdc++/96803] std::tuple chooses wrong constructor for uses-allocator construction
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
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2020-08-26 18:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96803
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This is not a regression, it's been wrong since I added uses-allocator
construction in r174443.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libstdc++/96803] std::tuple chooses wrong constructor for uses-allocator construction
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
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-08-26 18:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96803
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:
https://gcc.gnu.org/g:5494edae83ad33c769bd1ebc98f0c492453a6417
commit r11-2887-g5494edae83ad33c769bd1ebc98f0c492453a6417
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Aug 26 19:32:30 2020 +0100
libstdc++: Use correct argument type for __use_alloc [PR 96803]
The _Tuple_impl constructor for allocator-extended construction from a
different tuple type uses the _Tuple_impl's own _Head type in the
__use_alloc test. That is incorrect, because the argument tuple could
have a different type. Using the wrong type might select the
leading-allocator convention when it should use the trailing-allocator
convention, or vice versa.
libstdc++-v3/ChangeLog:
PR libstdc++/96803
* include/std/tuple
(_Tuple_impl(allocator_arg_t, Alloc, const _Tuple_impl<U...>&)):
Replace parameter pack with a type parameter and a pack and pass
the first type to __use_alloc.
* testsuite/20_util/tuple/cons/96803.cc: New test.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libstdc++/96803] std::tuple chooses wrong constructor for uses-allocator construction
2020-08-26 17:16 [Bug libstdc++/96803] New: std::tuple chooses wrong constructor for uses-allocator construction redi at gcc dot gnu.org
` (2 preceding siblings ...)
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
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-09-22 6:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96803
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:
https://gcc.gnu.org/g:248cca20c763bdb43af0628fb04e131868493cd2
commit r10-8786-g248cca20c763bdb43af0628fb04e131868493cd2
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Aug 26 19:32:30 2020 +0100
libstdc++: Use correct argument type for __use_alloc [PR 96803]
The _Tuple_impl constructor for allocator-extended construction from a
different tuple type uses the _Tuple_impl's own _Head type in the
__use_alloc test. That is incorrect, because the argument tuple could
have a different type. Using the wrong type might select the
leading-allocator convention when it should use the trailing-allocator
convention, or vice versa.
libstdc++-v3/ChangeLog:
PR libstdc++/96803
* include/std/tuple
(_Tuple_impl(allocator_arg_t, Alloc, const _Tuple_impl<U...>&)):
Replace parameter pack with a type parameter and a pack and pass
the first type to __use_alloc.
* testsuite/20_util/tuple/cons/96803.cc: New test.
(cherry picked from commit 5494edae83ad33c769bd1ebc98f0c492453a6417)
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libstdc++/96803] std::tuple chooses wrong constructor for uses-allocator construction
2020-08-26 17:16 [Bug libstdc++/96803] New: std::tuple chooses wrong constructor for uses-allocator construction redi at gcc dot gnu.org
` (3 preceding siblings ...)
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
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-09-22 6:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96803
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:
https://gcc.gnu.org/g:4be18e2f16bccad652c7deddf04284804d7be530
commit r9-8930-g4be18e2f16bccad652c7deddf04284804d7be530
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Aug 26 19:32:30 2020 +0100
libstdc++: Use correct argument type for __use_alloc [PR 96803]
The _Tuple_impl constructor for allocator-extended construction from a
different tuple type uses the _Tuple_impl's own _Head type in the
__use_alloc test. That is incorrect, because the argument tuple could
have a different type. Using the wrong type might select the
leading-allocator convention when it should use the trailing-allocator
convention, or vice versa.
libstdc++-v3/ChangeLog:
PR libstdc++/96803
* include/std/tuple
(_Tuple_impl(allocator_arg_t, Alloc, const _Tuple_impl<U...>&)):
Replace parameter pack with a type parameter and a pack and pass
the first type to __use_alloc.
* testsuite/20_util/tuple/cons/96803.cc: New test.
(cherry picked from commit 5494edae83ad33c769bd1ebc98f0c492453a6417)
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libstdc++/96803] std::tuple chooses wrong constructor for uses-allocator construction
2020-08-26 17:16 [Bug libstdc++/96803] New: std::tuple chooses wrong constructor for uses-allocator construction redi at gcc dot gnu.org
` (4 preceding siblings ...)
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
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-09-22 7:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96803
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:
https://gcc.gnu.org/g:7825399092d572ce8ea82c4aa8dfeb65076b0e52
commit r11-3348-g7825399092d572ce8ea82c4aa8dfeb65076b0e52
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Tue Sep 22 08:42:18 2020 +0100
libstdc++: Use correct argument type for __use_alloc, again [PR 96803]
While backporting 5494edae83ad33c769bd1ebc98f0c492453a6417 I noticed
that it's still not correct. I made the allocator-extended constructor
use the right type for the uses-allocator construction detection, but I
used an rvalue when it should be a const lvalue.
This should fix it properly this time.
libstdc++-v3/ChangeLog:
PR libstdc++/96803
* include/std/tuple
(_Tuple_impl(allocator_arg_t, Alloc, const _Tuple_impl<U...>&)):
Use correct value category in __use_alloc call.
* testsuite/20_util/tuple/cons/96803.cc: Check with constructors
that require correct value category to be used.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libstdc++/96803] std::tuple chooses wrong constructor for uses-allocator construction
2020-08-26 17:16 [Bug libstdc++/96803] New: std::tuple chooses wrong constructor for uses-allocator construction redi at gcc dot gnu.org
` (5 preceding siblings ...)
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
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-09-22 9:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96803
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:
https://gcc.gnu.org/g:5a981195bd80ad64475bbc24b7a4d222a6a6eff5
commit r10-8787-g5a981195bd80ad64475bbc24b7a4d222a6a6eff5
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Tue Sep 22 08:42:18 2020 +0100
libstdc++: Use correct argument type for __use_alloc, again [PR 96803]
While backporting 5494edae83ad33c769bd1ebc98f0c492453a6417 I noticed
that it's still not correct. I made the allocator-extended constructor
use the right type for the uses-allocator construction detection, but I
used an rvalue when it should be a const lvalue.
This should fix it properly this time.
libstdc++-v3/ChangeLog:
PR libstdc++/96803
* include/std/tuple
(_Tuple_impl(allocator_arg_t, Alloc, const _Tuple_impl<U...>&)):
Use correct value category in __use_alloc call.
* testsuite/20_util/tuple/cons/96803.cc: Check with constructors
that require correct value category to be used.
(cherry picked from commit 7825399092d572ce8ea82c4aa8dfeb65076b0e52)
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libstdc++/96803] std::tuple chooses wrong constructor for uses-allocator construction
2020-08-26 17:16 [Bug libstdc++/96803] New: std::tuple chooses wrong constructor for uses-allocator construction redi at gcc dot gnu.org
` (6 preceding siblings ...)
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
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-09-22 9:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96803
--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:
https://gcc.gnu.org/g:132ddcc78c118a6ab52063193462bf2a6dbdae32
commit r9-8931-g132ddcc78c118a6ab52063193462bf2a6dbdae32
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Tue Sep 22 08:42:18 2020 +0100
libstdc++: Use correct argument type for __use_alloc, again [PR 96803]
While backporting 5494edae83ad33c769bd1ebc98f0c492453a6417 I noticed
that it's still not correct. I made the allocator-extended constructor
use the right type for the uses-allocator construction detection, but I
used an rvalue when it should be a const lvalue.
This should fix it properly this time.
libstdc++-v3/ChangeLog:
PR libstdc++/96803
* include/std/tuple
(_Tuple_impl(allocator_arg_t, Alloc, const _Tuple_impl<U...>&)):
Use correct value category in __use_alloc call.
* testsuite/20_util/tuple/cons/96803.cc: Check with constructors
that require correct value category to be used.
(cherry picked from commit 7825399092d572ce8ea82c4aa8dfeb65076b0e52)
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libstdc++/96803] std::tuple chooses wrong constructor for uses-allocator construction
2020-08-26 17:16 [Bug libstdc++/96803] New: std::tuple chooses wrong constructor for uses-allocator construction redi at gcc dot gnu.org
` (7 preceding siblings ...)
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
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-09-22 9:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96803
--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-8 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:
https://gcc.gnu.org/g:6e86f0926f8de014cb0b0218442812e9f3ea8e95
commit r8-10525-g6e86f0926f8de014cb0b0218442812e9f3ea8e95
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Tue Sep 22 09:39:33 2020 +0100
libstdc++: Use correct argument type for __use_alloc [PR 96803]
The _Tuple_impl constructor for allocator-extended construction from a
different tuple type uses the _Tuple_impl's own _Head type in the
__use_alloc test. That is incorrect, because the argument tuple could
have a different type. Using the wrong type might select the
leading-allocator convention when it should use the trailing-allocator
convention, or vice versa.
This backport includes the value category fix from r11-3348.
libstdc++-v3/ChangeLog:
PR libstdc++/96803
* include/std/tuple
(_Tuple_impl(allocator_arg_t, Alloc, const _Tuple_impl<U...>&)):
Replace parameter pack with a type parameter and a pack and pass
the first type to __use_alloc.
* testsuite/20_util/tuple/cons/96803.cc: New test.
(cherry picked from commit 5494edae83ad33c769bd1ebc98f0c492453a6417)
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libstdc++/96803] std::tuple chooses wrong constructor for uses-allocator construction
2020-08-26 17:16 [Bug libstdc++/96803] New: std::tuple chooses wrong constructor for uses-allocator construction redi at gcc dot gnu.org
` (8 preceding siblings ...)
2020-09-22 9:41 ` cvs-commit at gcc dot gnu.org
@ 2020-09-22 9:41 ` redi at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2020-09-22 9:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96803
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
Target Milestone|--- |8.5
--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed for 8.5, 9.4 and 10.3
^ 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).