public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/102257] New: call of overloaded 'tuple' is ambiguous
@ 2021-09-09 13:51 hewillk at gmail dot com
2021-09-09 17:18 ` [Bug c++/102257] " pinskia at gcc dot gnu.org
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: hewillk at gmail dot com @ 2021-09-09 13:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102257
Bug ID: 102257
Summary: call of overloaded 'tuple' is ambiguous
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: hewillk at gmail dot com
Target Milestone: ---
The following code failed since gcc-11, which seems to be a language bug.
#include <tuple>
#include <string>
int main() {
std::tuple<std::string, int> t{{}, 0};
}
https://godbolt.org/z/qMfhxoss3
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/102257] call of overloaded 'tuple' is ambiguous
2021-09-09 13:51 [Bug c++/102257] New: call of overloaded 'tuple' is ambiguous hewillk at gmail dot com
@ 2021-09-09 17:18 ` pinskia at gcc dot gnu.org
2021-09-09 20:34 ` pinskia at gcc dot gnu.org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-09 17:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102257
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=102247
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Take:
#include <tuple>
#include <string>
int main() {
std::tuple<std::string, int, int> t{{}, 0};
}
----- CUT ----
GCC does reject this though with the following error message:
<source>: In function 'int main()':
<source>:6:44: error: converting to 'std::allocator_arg_t' from initializer
list would use explicit constructor 'constexpr
std::allocator_arg_t::allocator_arg_t()'
6 | std::tuple<std::string, int, int> t{{}, 0};
| ^
So the question becomese does the conversion happen while chosing the overload
for the tuple constructor?
Looks like GCC is the only one which rejects this as being ambiguous too.
I did try:
struct tag{};
struct alloc {explicit alloc(int){};};
template<typename T1, typename T2>
struct tuple {
tuple(tag, const alloc&);
tuple(const T1&, const T2&);
};
class t2{};
tuple<t2,int> tt{{},0};
and GCC accepts this so is suprising based on the error message of the other
one.
Also you don't need std::string, a simple class like this will fail:
#include <tuple>
class t2{};
int main() {
std::tuple<t2, int> t{{}, 0};
}
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/102257] call of overloaded 'tuple' is ambiguous
2021-09-09 13:51 [Bug c++/102257] New: call of overloaded 'tuple' is ambiguous hewillk at gmail dot com
2021-09-09 17:18 ` [Bug c++/102257] " pinskia at gcc dot gnu.org
@ 2021-09-09 20:34 ` pinskia at gcc dot gnu.org
2021-09-10 3:55 ` hewillk at gmail dot com
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-09 20:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102257
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
See https://wg21.link/cwg1228 this might be invalid code and GCC is correct in
rejecting it.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/102257] call of overloaded 'tuple' is ambiguous
2021-09-09 13:51 [Bug c++/102257] New: call of overloaded 'tuple' is ambiguous hewillk at gmail dot com
2021-09-09 17:18 ` [Bug c++/102257] " pinskia at gcc dot gnu.org
2021-09-09 20:34 ` pinskia at gcc dot gnu.org
@ 2021-09-10 3:55 ` hewillk at gmail dot com
2021-09-14 15:31 ` ppalka at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: hewillk at gmail dot com @ 2021-09-10 3:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102257
--- Comment #3 from 康桓瑋 <hewillk at gmail dot com> ---
(In reply to Andrew Pinski from comment #2)
> See https://wg21.link/cwg1228 this might be invalid code and GCC is correct
> in rejecting it.
Maybe. But why does GCC accept the following?
#include <tuple>
#include <string>
int main() {
std::tuple<std::string, int> t{{}, {}};
}
https://godbolt.org/z/ePovjh3fa
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/102257] call of overloaded 'tuple' is ambiguous
2021-09-09 13:51 [Bug c++/102257] New: call of overloaded 'tuple' is ambiguous hewillk at gmail dot com
` (2 preceding siblings ...)
2021-09-10 3:55 ` hewillk at gmail dot com
@ 2021-09-14 15:31 ` ppalka at gcc dot gnu.org
2024-03-27 13:38 ` redi at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-09-14 15:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102257
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ppalka at gcc dot gnu.org
--- Comment #4 from Patrick Palka <ppalka at gcc dot gnu.org> ---
(In reply to 康桓瑋 from comment #3)
> (In reply to Andrew Pinski from comment #2)
> > See https://wg21.link/cwg1228 this might be invalid code and GCC is correct
> > in rejecting it.
>
> Maybe. But why does GCC accept the following?
>
> #include <tuple>
> #include <string>
>
> int main() {
> std::tuple<std::string, int> t{{}, {}};
> }
>
> https://godbolt.org/z/ePovjh3fa
Looks like we accept this testcase because the template parameter _Alloc for
the template candidate
template<typename _Alloc,
_ImplicitDefaultCtor<is_object<_Alloc>::value, _T1, _T2> = true>
tuple(std::allocator_arg_t, const _Alloc&)
is no longer deducible (whereas in the original testcase _Alloc is deduced to
int here), so this candidate is discarded and the result of overload resolution
is no longer ambiguous.
(In reply to Andrew Pinski from comment #2)
> See https://wg21.link/cwg1228 this might be invalid code and GCC is correct
> in rejecting it.
Agreed FWIW
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/102257] call of overloaded 'tuple' is ambiguous
2021-09-09 13:51 [Bug c++/102257] New: call of overloaded 'tuple' is ambiguous hewillk at gmail dot com
` (3 preceding siblings ...)
2021-09-14 15:31 ` ppalka at gcc dot gnu.org
@ 2024-03-27 13:38 ` redi at gcc dot gnu.org
2024-03-27 13:39 ` redi at gcc dot gnu.org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2024-03-27 13:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102257
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I think this is the same bug, reduced from Bug 100667 comment 1 (where it
wasn't related):
struct allocator_arg_t { explicit allocator_arg_t() = default; };
class string{};
class Foo{};
struct tuple
{
template<typename Alloc>
tuple(allocator_arg_t, const Alloc&) { }
template<typename = void>
tuple(const string&, const Foo&) { }
};
tuple bar()
{
return { {}, Foo{}};
}
Clang and EDG accept this.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/102257] call of overloaded 'tuple' is ambiguous
2021-09-09 13:51 [Bug c++/102257] New: call of overloaded 'tuple' is ambiguous hewillk at gmail dot com
` (4 preceding siblings ...)
2024-03-27 13:38 ` redi at gcc dot gnu.org
@ 2024-03-27 13:39 ` redi at gcc dot gnu.org
2024-05-02 9:23 ` redi at gcc dot gnu.org
2024-05-02 9:28 ` redi at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2024-03-27 13:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102257
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #2)
> See https://wg21.link/cwg1228 this might be invalid code and GCC is correct
> in rejecting it.
So dup of PR 84849 ?
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/102257] call of overloaded 'tuple' is ambiguous
2021-09-09 13:51 [Bug c++/102257] New: call of overloaded 'tuple' is ambiguous hewillk at gmail dot com
` (5 preceding siblings ...)
2024-03-27 13:39 ` redi at gcc dot gnu.org
@ 2024-05-02 9:23 ` redi at gcc dot gnu.org
2024-05-02 9:28 ` redi at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2024-05-02 9:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102257
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |arthur.j.odwyer at gmail dot com
--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
*** Bug 114898 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c++/102257] call of overloaded 'tuple' is ambiguous
2021-09-09 13:51 [Bug c++/102257] New: call of overloaded 'tuple' is ambiguous hewillk at gmail dot com
` (6 preceding siblings ...)
2024-05-02 9:23 ` redi at gcc dot gnu.org
@ 2024-05-02 9:28 ` redi at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2024-05-02 9:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102257
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Last reconfirmed| |2024-05-02
--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #6)
> (In reply to Andrew Pinski from comment #2)
> > See https://wg21.link/cwg1228 this might be invalid code and GCC is correct
> > in rejecting it.
>
> So dup of PR 84849 ?
This seems more closely related to Bug 113300, i.e. CWG 2856, because this is
about explicit default ctors not explicit copy/move ctors.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-05-02 9:28 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-09 13:51 [Bug c++/102257] New: call of overloaded 'tuple' is ambiguous hewillk at gmail dot com
2021-09-09 17:18 ` [Bug c++/102257] " pinskia at gcc dot gnu.org
2021-09-09 20:34 ` pinskia at gcc dot gnu.org
2021-09-10 3:55 ` hewillk at gmail dot com
2021-09-14 15:31 ` ppalka at gcc dot gnu.org
2024-03-27 13:38 ` redi at gcc dot gnu.org
2024-03-27 13:39 ` redi at gcc dot gnu.org
2024-05-02 9:23 ` redi at gcc dot gnu.org
2024-05-02 9:28 ` 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).