public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "bbi5291 at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/110774] New: Ambiguous partial ordering with non-dependent function parameter type Date: Sat, 22 Jul 2023 01:03:01 +0000 [thread overview] Message-ID: <bug-110774-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110774 Bug ID: 110774 Summary: Ambiguous partial ordering with non-dependent function parameter type Product: gcc Version: 13.1.0 Status: UNCONFIRMED Keywords: rejects-valid Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: bbi5291 at gmail dot com Target Milestone: --- With `g++ -std=c++2b`, the following is rejected: --- template<typename T> struct A { typedef char* type; }; template<typename T> char* f1(T, char*); // #1 template<typename T> long* f1(T*, typename A<T>::type*); // #2 long* p1 = f1(p1, 0); // #3 --- The error message is: --- <source>:7:14: error: call of overloaded 'f1(long int*&, int)' is ambiguous 7 | long* p1 = f1(p1, 0); // #3 | ~~^~~~~~~ <source>:4:28: note: candidate: 'char* f1(T, char*) [with T = long int*]' 4 | template<typename T> char* f1(T, char*); // #1 | ^~ <source>:5:28: note: candidate: 'long int* f1(T*, typename A<T>::type*) [with T = long int; typename A<T>::type = char*]' 5 | template<typename T> long* f1(T*, typename A<T>::type*); // #2 | ^~ --- This code is very similar to the code from Core issue 455, but one of the function parameters has been changed from containing `T` in a non-deduced context to not containing `T` at all. Since the code from core issue 455 is supposed to be valid (#2 being chosen) I cannot see any reason why this example would not also be valid. A non-dependent parameter type should be treated the same as a parameter type containing the template parameter in a non-deduced context: in either case, it cannot be used for deduction. Clang and MSVC also reject this code, but I cannot find any reason why. Is it possible that all 3 compilers have a bug? Reflector thread: https://lists.isocpp.org/core/2023/07/14533.php
next reply other threads:[~2023-07-22 1:03 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-07-22 1:03 bbi5291 at gmail dot com [this message] 2023-07-22 1:04 ` [Bug c++/110774] " pinskia at gcc dot gnu.org 2023-07-22 1:07 ` pinskia at gcc dot gnu.org 2023-07-22 1:12 ` pinskia at gcc dot gnu.org 2023-07-22 1:15 ` [Bug c++/110774] Ambiguous partial ordering with non-dependent function parameter type and nullptr pinskia at gcc dot gnu.org 2023-07-22 1:17 ` bbi5291 at gmail dot com
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-110774-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: linkBe 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).