public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "brooks at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/104218] New: 23_containers/vector/ext_pointer/types tests rely on GCC overload-resolution bug
Date: Tue, 25 Jan 2022 01:53:01 +0000 [thread overview]
Message-ID: <bug-104218-4@http.gcc.gnu.org/bugzilla/> (raw)
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.
----
next reply other threads:[~2022-01-25 1:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-25 1:53 brooks at gcc dot gnu.org [this message]
2022-01-25 3:08 ` [Bug libstdc++/104218] " pinskia at gcc dot gnu.org
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-104218-4@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).