https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108676

            Bug ID: 108676
           Summary: GCC prints function signature incorrectly
           Product: gcc
           Version: 12.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vanyacpp at gmail dot com
  Target Milestone: ---

Consider this code:

template <typename T>
struct X
{};

template <typename U>
X<U&> f();

template <typename V>
X<V&> g();

int main()
{
    g<void>();
}

On GCC 12.2 it gives this error message:

<source>:13:12: error: no matching function for call to 'g<void>()'
   13 |     g<void>();
      |     ~~~~~~~^~
<source>:9:7: note: candidate: 'template<class V> X<U&> g()'
    9 | X<V&> g();
      |       ^

Please note that the return type of 'g' is printed incorrectly. It should say
'X<V&>' instead of 'X<U&>'.

https://godbolt.org/z/EeWoo16M

Reply via email to