public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/110774] New: Ambiguous partial ordering with non-dependent function parameter type
@ 2023-07-22  1:03 bbi5291 at gmail dot com
  2023-07-22  1:04 ` [Bug c++/110774] " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: bbi5291 at gmail dot com @ 2023-07-22  1:03 UTC (permalink / raw)
  To: gcc-bugs

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-07-22  1:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-22  1:03 [Bug c++/110774] New: Ambiguous partial ordering with non-dependent function parameter type bbi5291 at gmail dot com
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

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).