https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111113
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Status|UNCONFIRMED |NEW Last reconfirmed| |2023-08-23 --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Confirmed. Another testcase which might show what is really going on: ``` auto foo() { struct A; void bar(const A&); struct A { friend void bar(const A&); }; bar(A{}); return A{}; } using A = decltype(foo()); void bar(const A&) {} int main() { bar(foo()); } ``` We get the following error message: ``` <source>: In function 'int main()': <source>:16:12: error: call of overloaded 'bar(foo()::A)' is ambiguous 16 | bar(foo()); | ~~~^~~~~~~ <source>:12:6: note: candidate: 'void bar(const A&)' 12 | void bar(const A&) {} | ^~~ <source>:5:21: note: candidate: 'void bar(const foo()::A&)' 5 | friend void bar(const A&); | ^~~ ``` Which is not correct as bar in this case is the same bar.