From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E13DF385DC0C; Sat, 22 Jul 2023 01:03:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E13DF385DC0C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689987783; bh=hW/R+BXK87/KhDkbx2pDPA9+UvOih2nwdHu9NDyiWtM=; h=From:To:Subject:Date:From; b=Kq1rLlsMXrSomY84oKzDIVyhOEKwd+9uEwfsZvkbvZF1fJwnkVz+ys0GOem9e5tTd /pQf7UoPclazBUsR/JZpIPhxkHkJPZ0KEPj7XGezqnF6TKHrz//kmyRvCCeWgpyby6 EX4gveXB1lev0WvDhEgOCT1/gbbfWAGiX5g//VHc= From: "bbi5291 at gmail dot com" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.1.0 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: bbi5291 at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110774 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=3Dc++2b`, the following is rejected: --- template struct A { typedef char* type; }; template char* f1(T, char*); // #1 template long* f1(T*, typename A::type*); // #2 long* p1 =3D f1(p1, 0); // #3 --- The error message is: --- :7:14: error: call of overloaded 'f1(long int*&, int)' is ambiguous 7 | long* p1 =3D f1(p1, 0); // #3 | ~~^~~~~~~ :4:28: note: candidate: 'char* f1(T, char*) [with T =3D long int*]' 4 | template char* f1(T, char*); // #1 | ^~ :5:28: note: candidate: 'long int* f1(T*, typename A::type*) [wi= th T =3D long int; typename A::type =3D char*]' 5 | template long* f1(T*, typename A::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 exa= mple would not also be valid. A non-dependent parameter type should be treated t= he 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=