public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/61947] New: Ambiguous calls when constructing std::tuple
@ 2014-07-29 11:07 roman.perepelitsa at gmail dot com
2014-07-29 11:35 ` [Bug libstdc++/61947] [4.8/4.9/4.10 Regression] " redi at gcc dot gnu.org
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: roman.perepelitsa at gmail dot com @ 2014-07-29 11:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61947
Bug ID: 61947
Summary: Ambiguous calls when constructing std::tuple
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: roman.perepelitsa at gmail dot com
#include <tuple>
struct ConvertibleToAny {
template <class T> operator T() const { return T(); }
};
int main() {
std::tuple<ConvertibleToAny&&> t(ConvertibleToAny{});
}
Produces:
third_party/crosstool/v17/stable/gcc-x86_64-grtev3-linux-gnu/x86_64-grtev3-linux-gnu/include/c++/4.8.x-google/tuple:262:4:
error: call to constructor of '_Head_base<0UL, (anonymous
namespace)::ConvertibleToAny &&, __empty_not_final<ConvertibleToAny
&&>::value>' is ambiguous
_Base(std::forward<_UHead>(__head)) { }
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
third_party/crosstool/v17/stable/gcc-x86_64-grtev3-linux-gnu/x86_64-grtev3-linux-gnu/include/c++/4.8.x-google/tuple:405:4:
note: in instantiation of function template specialization 'std::_Tuple_impl<0,
(anonymous namespace)::ConvertibleToAny &&>::_Tuple_impl<(anonymous
namespace)::ConvertibleToAny, void>' requested here
: _Inherited(std::forward<_UElements>(__elements)...) { }
^
experimental/users/romanp/tuple_bug/tuple-bug.cc:13:34: note: in instantiation
of function template specialization 'std::tuple<(anonymous
namespace)::ConvertibleToAny &&>::tuple<(anonymous
namespace)::ConvertibleToAny, void>' requested here
std::tuple<ConvertibleToAny&&> t(ConvertibleToAny{});
^
third_party/crosstool/v17/stable/gcc-x86_64-grtev3-linux-gnu/x86_64-grtev3-linux-gnu/include/c++/4.8.x-google/tuple:128:12:
note: candidate is the implicit move constructor
struct _Head_base<_Idx, _Head, false>
^
third_party/crosstool/v17/stable/gcc-x86_64-grtev3-linux-gnu/x86_64-grtev3-linux-gnu/include/c++/4.8.x-google/tuple:128:12:
note: candidate constructor (the implicit copy constructor) has been implicitly
deleted
third_party/crosstool/v17/stable/gcc-x86_64-grtev3-linux-gnu/x86_64-grtev3-linux-gnu/include/c++/4.8.x-google/tuple:142:7:
note: candidate constructor
_Head_base(__uses_alloc0)
The call shouldn't be ambiguous. It should pick the following constructor:
[tuple.cnstr]
template <class... UTypes>
explicit tuple(UTypes&&... u);
Requires: sizeof...(Types) == sizeof...(UTypes). is_constructible<Ti , Ui
&&>::value is true for all i.
Effects: Initializes the elements in the tuple with the corresponding value
in std::forward<UTypes>(u).
is_constructible<ConvertibleToAny&&, ConvertibleToAny&&>::value is true, so the
precondition is satisfied.
This bug affects std::bind as it's built on top of std::tuple.
#include <functional>
struct ConvertibleToAny {
template <class T> operator T() const { return T(); }
};
void Sink(int) {}
int main() {
std::bind(Sink, std::placeholders::_1)(ConvertibleToAny{});
}
Error:
third_party/crosstool/v17/stable/gcc-x86_64-grtev3-linux-gnu/x86_64-grtev3-linux-gnu/include/c++/4.8.x-google/tuple:262:4:
error: call to constructor of '_Head_base<0UL, (anonymous
namespace)::ConvertibleToAny &&, __empty_not_final<ConvertibleToAny
&&>::value>' is ambiguous
_Base(std::forward<_UHead>(__head)) { }
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
third_party/crosstool/v17/stable/gcc-x86_64-grtev3-linux-gnu/x86_64-grtev3-linux-gnu/include/c++/4.8.x-google/tuple:405:4:
note: in instantiation of function template specialization 'std::_Tuple_impl<0,
(anonymous namespace)::ConvertibleToAny &&>::_Tuple_impl<(anonymous
namespace)::ConvertibleToAny, void>' requested here
: _Inherited(std::forward<_UElements>(__elements)...) { }
^
third_party/crosstool/v17/stable/gcc-x86_64-grtev3-linux-gnu/x86_64-grtev3-linux-gnu/include/c++/4.8.x-google/tuple:868:14:
note: in instantiation of function template specialization
'std::tuple<(anonymous namespace)::ConvertibleToAny &&>::tuple<(anonymous
namespace)::ConvertibleToAny, void>' requested here
{ return tuple<_Elements&&...>(std::forward<_Elements>(__args)...); }
^
third_party/crosstool/v17/stable/gcc-x86_64-grtev3-linux-gnu/x86_64-grtev3-linux-gnu/include/c++/4.8.x-google/functional:1354:13:
note: in instantiation of function template specialization
'std::forward_as_tuple<(anonymous namespace)::ConvertibleToAny>' requested here
std::forward_as_tuple(std::forward<_Args>(__args)...),
^
experimental/users/romanp/tuple_bug/tuple-bug.cc:15:41: note: in instantiation
of function template specialization 'std::_Bind<void
(*(std::_Placeholder<1>))(int)>::operator()<(anonymous
namespace)::ConvertibleToAny, void>' requested here
std::bind(Sink, std::placeholders::_1)(ConvertibleToAny{});
^
third_party/crosstool/v17/stable/gcc-x86_64-grtev3-linux-gnu/x86_64-grtev3-linux-gnu/include/c++/4.8.x-google/tuple:128:12:
note: candidate is the implicit move constructor
struct _Head_base<_Idx, _Head, false>
^
third_party/crosstool/v17/stable/gcc-x86_64-grtev3-linux-gnu/x86_64-grtev3-linux-gnu/include/c++/4.8.x-google/tuple:128:12:
note: candidate constructor (the implicit copy constructor) has been implicitly
deleted
third_party/crosstool/v17/stable/gcc-x86_64-grtev3-linux-gnu/x86_64-grtev3-linux-gnu/include/c++/4.8.x-google/tuple:142:7:
note: candidate constructor
_Head_base(__uses_alloc0)
^
third_party/crosstool/v17/stable/gcc-x86_64-grtev3-linux-gnu/x86_64-grtev3-linux-gnu/include/c++/4.8.x-google/tuple:271:2:
error: call to constructor of '_Head_base<0UL, (anonymous
namespace)::ConvertibleToAny &&, __empty_not_final<ConvertibleToAny
&&>::value>' is ambiguous
_Base(std::forward<_Head>(_M_head(__in))) { }
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
third_party/crosstool/v17/stable/gcc-x86_64-grtev3-linux-gnu/x86_64-grtev3-linux-gnu/include/c++/4.8.x-google/tuple:409:17:
note: in instantiation of member function 'std::_Tuple_impl<0, (anonymous
namespace)::ConvertibleToAny &&>::_Tuple_impl' requested here
constexpr tuple(tuple&&) = default;
^
third_party/crosstool/v17/stable/gcc-x86_64-grtev3-linux-gnu/x86_64-grtev3-linux-gnu/include/c++/4.8.x-google/functional:1354:13:
note: in instantiation of function template specialization
'std::forward_as_tuple<(anonymous namespace)::ConvertibleToAny>' requested here
std::forward_as_tuple(std::forward<_Args>(__args)...),
^
experimental/users/romanp/tuple_bug/tuple-bug.cc:15:41: note: in instantiation
of function template specialization 'std::_Bind<void
(*(std::_Placeholder<1>))(int)>::operator()<(anonymous
namespace)::ConvertibleToAny, void>' requested here
std::bind(Sink, std::placeholders::_1)(ConvertibleToAny{});
^
third_party/crosstool/v17/stable/gcc-x86_64-grtev3-linux-gnu/x86_64-grtev3-linux-gnu/include/c++/4.8.x-google/tuple:128:12:
note: candidate is the implicit move constructor
struct _Head_base<_Idx, _Head, false>
^
third_party/crosstool/v17/stable/gcc-x86_64-grtev3-linux-gnu/x86_64-grtev3-linux-gnu/include/c++/4.8.x-google/tuple:128:12:
note: candidate constructor (the implicit copy constructor) has been implicitly
deleted
third_party/crosstool/v17/stable/gcc-x86_64-grtev3-linux-gnu/x86_64-grtev3-linux-gnu/include/c++/4.8.x-google/tuple:142:7:
note: candidate constructor
_Head_base(__uses_alloc0)
^
third_party/crosstool/v17/stable/gcc-x86_64-grtev3-linux-gnu/x86_64-grtev3-linux-gnu/include/c++/4.8.x-google/tuple:868:14:
note: implicit move constructor for 'std::tuple<(anonymous
namespace)::ConvertibleToAny &&>' first required here
{ return tuple<_Elements&&...>(std::forward<_Elements>(__args)...); }
^
This bug appears to be a regression from libstdc++ 4.6, where the code was
accepted.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/61947] [4.8/4.9/4.10 Regression] Ambiguous calls when constructing std::tuple
2014-07-29 11:07 [Bug libstdc++/61947] New: Ambiguous calls when constructing std::tuple roman.perepelitsa at gmail dot com
@ 2014-07-29 11:35 ` redi at gcc dot gnu.org
2014-07-29 11:54 ` redi at gcc dot gnu.org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2014-07-29 11:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61947
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2014-07-29
Known to work| |4.6.4
Assignee|unassigned at gcc dot gnu.org |redi at gcc dot gnu.org
Summary|Ambiguous calls when |[4.8/4.9/4.10 Regression]
|constructing std::tuple |Ambiguous calls when
| |constructing std::tuple
Ever confirmed|0 |1
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
stupid allocators
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/61947] [4.8/4.9/4.10 Regression] Ambiguous calls when constructing std::tuple
2014-07-29 11:07 [Bug libstdc++/61947] New: Ambiguous calls when constructing std::tuple roman.perepelitsa at gmail dot com
2014-07-29 11:35 ` [Bug libstdc++/61947] [4.8/4.9/4.10 Regression] " redi at gcc dot gnu.org
@ 2014-07-29 11:54 ` redi at gcc dot gnu.org
2014-07-29 15:17 ` ppluzhnikov at google dot com
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2014-07-29 11:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61947
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Created attachment 33203
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33203&action=edit
proposed patch
Add std::allocator_arg_t parameter to unary _Head_base constructors taking a
__uses_allocN tag type, so that they are not candidates for calls with one
parameter. This allows the !is_convertible constraint to be removed from the
_Head_base::_Head_base(__UHead&&) constructor.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/61947] [4.8/4.9/4.10 Regression] Ambiguous calls when constructing std::tuple
2014-07-29 11:07 [Bug libstdc++/61947] New: Ambiguous calls when constructing std::tuple roman.perepelitsa at gmail dot com
2014-07-29 11:35 ` [Bug libstdc++/61947] [4.8/4.9/4.10 Regression] " redi at gcc dot gnu.org
2014-07-29 11:54 ` redi at gcc dot gnu.org
@ 2014-07-29 15:17 ` ppluzhnikov at google dot com
2014-07-29 17:31 ` redi at gcc dot gnu.org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: ppluzhnikov at google dot com @ 2014-07-29 15:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61947
Paul Pluzhnikov <ppluzhnikov at google dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ppluzhnikov at google dot com
--- Comment #3 from Paul Pluzhnikov <ppluzhnikov at google dot com> ---
Google ref: b/16644819
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/61947] [4.8/4.9/4.10 Regression] Ambiguous calls when constructing std::tuple
2014-07-29 11:07 [Bug libstdc++/61947] New: Ambiguous calls when constructing std::tuple roman.perepelitsa at gmail dot com
` (2 preceding siblings ...)
2014-07-29 15:17 ` ppluzhnikov at google dot com
@ 2014-07-29 17:31 ` redi at gcc dot gnu.org
2014-07-29 17:34 ` redi at gcc dot gnu.org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2014-07-29 17:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61947
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Author: redi
Date: Tue Jul 29 17:30:34 2014
New Revision: 213221
URL: https://gcc.gnu.org/viewcvs?rev=213221&root=gcc&view=rev
Log:
PR libstdc++/61947
* include/std/tuple (_Head_base): Use allocator_arg_t parameters to
disambiguate unary constructors.
(_Tuple_impl): Pass allocator_arg_t arguments.
* testsuite/20_util/tuple/61947.cc: New.
* testsuite/20_util/uses_allocator/cons_neg.cc: Adjust dg-error line.
Added:
trunk/libstdc++-v3/testsuite/20_util/tuple/61947.cc
- copied, changed from r213220,
trunk/libstdc++-v3/testsuite/20_util/uses_allocator/cons_neg.cc
Modified:
trunk/libstdc++-v3/ChangeLog
trunk/libstdc++-v3/include/std/tuple
trunk/libstdc++-v3/testsuite/20_util/uses_allocator/cons_neg.cc
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/61947] [4.8/4.9/4.10 Regression] Ambiguous calls when constructing std::tuple
2014-07-29 11:07 [Bug libstdc++/61947] New: Ambiguous calls when constructing std::tuple roman.perepelitsa at gmail dot com
` (3 preceding siblings ...)
2014-07-29 17:31 ` redi at gcc dot gnu.org
@ 2014-07-29 17:34 ` redi at gcc dot gnu.org
2014-11-19 13:30 ` [Bug libstdc++/61947] [4.8/4.9 " rguenth at gcc dot gnu.org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2014-07-29 17:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61947
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work| |4.10.0
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed on the trunk so far.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/61947] [4.8/4.9 Regression] Ambiguous calls when constructing std::tuple
2014-07-29 11:07 [Bug libstdc++/61947] New: Ambiguous calls when constructing std::tuple roman.perepelitsa at gmail dot com
` (4 preceding siblings ...)
2014-07-29 17:34 ` redi at gcc dot gnu.org
@ 2014-11-19 13:30 ` rguenth at gcc dot gnu.org
2014-12-06 20:38 ` redi at gcc dot gnu.org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-11-19 13:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61947
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |4.8.4
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/61947] [4.8/4.9 Regression] Ambiguous calls when constructing std::tuple
2014-07-29 11:07 [Bug libstdc++/61947] New: Ambiguous calls when constructing std::tuple roman.perepelitsa at gmail dot com
` (5 preceding siblings ...)
2014-11-19 13:30 ` [Bug libstdc++/61947] [4.8/4.9 " rguenth at gcc dot gnu.org
@ 2014-12-06 20:38 ` redi at gcc dot gnu.org
2014-12-06 22:24 ` redi at gcc dot gnu.org
2014-12-06 22:29 ` redi at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2014-12-06 20:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61947
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Author: redi
Date: Sat Dec 6 20:38:01 2014
New Revision: 218453
URL: https://gcc.gnu.org/viewcvs?rev=218453&root=gcc&view=rev
Log:
PR libstdc++/61947
* include/std/tuple (_Head_base): Use allocator_arg_t parameters to
disambiguate unary constructors.
(_Tuple_impl): Pass allocator_arg_t arguments.
* testsuite/20_util/tuple/61947.cc: New.
* testsuite/20_util/uses_allocator/cons_neg.cc: Adjust dg-error line.
Added:
branches/gcc-4_8-branch/libstdc++-v3/testsuite/20_util/tuple/61947.cc
- copied, changed from r218452,
branches/gcc-4_8-branch/libstdc++-v3/testsuite/20_util/uses_allocator/cons_neg.cc
Modified:
branches/gcc-4_8-branch/libstdc++-v3/ChangeLog
branches/gcc-4_8-branch/libstdc++-v3/include/std/tuple
branches/gcc-4_8-branch/libstdc++-v3/testsuite/20_util/uses_allocator/cons_neg.cc
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/61947] [4.8/4.9 Regression] Ambiguous calls when constructing std::tuple
2014-07-29 11:07 [Bug libstdc++/61947] New: Ambiguous calls when constructing std::tuple roman.perepelitsa at gmail dot com
` (6 preceding siblings ...)
2014-12-06 20:38 ` redi at gcc dot gnu.org
@ 2014-12-06 22:24 ` redi at gcc dot gnu.org
2014-12-06 22:29 ` redi at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2014-12-06 22:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61947
--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Author: redi
Date: Sat Dec 6 22:24:16 2014
New Revision: 218457
URL: https://gcc.gnu.org/viewcvs?rev=218457&root=gcc&view=rev
Log:
PR libstdc++/61947
* include/std/tuple (_Head_base): Use allocator_arg_t parameters to
disambiguate unary constructors.
(_Tuple_impl): Pass allocator_arg_t arguments.
* testsuite/20_util/tuple/61947.cc: New.
* testsuite/20_util/uses_allocator/cons_neg.cc: Adjust dg-error line.
Added:
branches/gcc-4_9-branch/libstdc++-v3/testsuite/20_util/tuple/61947.cc
- copied, changed from r218456,
branches/gcc-4_9-branch/libstdc++-v3/testsuite/20_util/uses_allocator/cons_neg.cc
Modified:
branches/gcc-4_9-branch/libstdc++-v3/ChangeLog
branches/gcc-4_9-branch/libstdc++-v3/include/std/tuple
branches/gcc-4_9-branch/libstdc++-v3/testsuite/20_util/uses_allocator/cons_neg.cc
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/61947] [4.8/4.9 Regression] Ambiguous calls when constructing std::tuple
2014-07-29 11:07 [Bug libstdc++/61947] New: Ambiguous calls when constructing std::tuple roman.perepelitsa at gmail dot com
` (7 preceding siblings ...)
2014-12-06 22:24 ` redi at gcc dot gnu.org
@ 2014-12-06 22:29 ` redi at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2014-12-06 22:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61947
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Known to work|4.10.0 |5.0
Resolution|--- |FIXED
--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed for 4.8.4 and 4.9.3 too
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2014-12-06 22:29 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-29 11:07 [Bug libstdc++/61947] New: Ambiguous calls when constructing std::tuple roman.perepelitsa at gmail dot com
2014-07-29 11:35 ` [Bug libstdc++/61947] [4.8/4.9/4.10 Regression] " redi at gcc dot gnu.org
2014-07-29 11:54 ` redi at gcc dot gnu.org
2014-07-29 15:17 ` ppluzhnikov at google dot com
2014-07-29 17:31 ` redi at gcc dot gnu.org
2014-07-29 17:34 ` redi at gcc dot gnu.org
2014-11-19 13:30 ` [Bug libstdc++/61947] [4.8/4.9 " rguenth at gcc dot gnu.org
2014-12-06 20:38 ` redi at gcc dot gnu.org
2014-12-06 22:24 ` redi at gcc dot gnu.org
2014-12-06 22:29 ` 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).