public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/104218] New: 23_containers/vector/ext_pointer/types tests rely on GCC overload-resolution bug
@ 2022-01-25 1:53 brooks at gcc dot gnu.org
2022-01-25 3:08 ` [Bug libstdc++/104218] " pinskia at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: brooks at gcc dot gnu.org @ 2022-01-25 1:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104218
Bug ID: 104218
Summary: 23_containers/vector/ext_pointer/types tests rely on
GCC overload-resolution bug
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: brooks at gcc dot gnu.org
Target Milestone: ---
In cleaning up some old internal bugs, I came across this one from years ago
when I was running the 4.9.4 libstdc++ testsuite through Clang, and it looks
like it's still relevant.
The 23_containers/vector/ext_pointer/types/{1,2}.cc programs compile
successfully with GCC, of course, but with Clang we get "use of overloaded
operator '-' is ambiguous" errors in std::vector<N::X,
__gnu_cxx::_ExtPtr_allocator<N::X> >.
This reduced testcase shows the difference in the two compilers' behavior:
----
template<typename T> struct X {
template<typename U> void operator-(const X<U>&);
};
template<typename T> void operator-(T, T);
void f(X<int> x) { x - x; }
----
Compiler explorer link: https://godbolt.org/z/nnb98W5nW
Richard Smith believes this is a GCC bug, not a Clang bug, per this analysis:
> GCC appears to believe the member function is more specialized, and calls it.
> Clang and I think that's wrong: deduction fails in both directions in partial
> ordering, so the call is ambiguous.
>
> Indeed, C++ DR 532 gives a very similar example. Following its rule, the above
> would be equivalent to:
>
> template<typename T> struct X {};
> template<typename T, typename U> void operator-(X<T> &, const X<U>&);
> template<typename T> void operator-(T, T);
>
> void f(X<int> x) { x - x; }
>
> ... which GCC and Clang agree is ambiguous. So: this test is relying on a GCC
> bug.
----
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug libstdc++/104218] 23_containers/vector/ext_pointer/types tests rely on GCC overload-resolution bug
2022-01-25 1:53 [Bug libstdc++/104218] New: 23_containers/vector/ext_pointer/types tests rely on GCC overload-resolution bug brooks at gcc dot gnu.org
@ 2022-01-25 3:08 ` pinskia at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-25 3:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104218
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=78291
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Maybe related to PR 78291.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-01-25 3:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-25 1:53 [Bug libstdc++/104218] New: 23_containers/vector/ext_pointer/types tests rely on GCC overload-resolution bug brooks at gcc dot gnu.org
2022-01-25 3:08 ` [Bug libstdc++/104218] " pinskia 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).