https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78925
Bug ID: 78925 Summary: Inline friend template function not hidden during ADL Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: bluescarni at gmail dot com Target Milestone: --- Consider the code: -------------- namespace ns { template <typename T> struct foo { template <typename U> friend void bar(U) {} }; } int main() { ns::foo<int> f_int; bar(f_int); ns::foo<double> f_double; bar(f_double); } -------------- Clang compiles this code without complaining, but every GCC version I have tried (namely, 5.4.0 and the current trunk) fails, complaining about the redefinition of ns::bar(). What seems to happen here is that during the lookup for the second bar() call, the instantiation of bar() triggered by the first call is considered via ADL, thus leading to two identical overloads being present at the same time in the candidate set.