[llvm-bugs] [Bug 42513] Friend function declarations hidden in qualifed name lookup (regression introduced by commit r350505)

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Oct 30 18:40:34 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=42513

Richard Smith <richard-llvm at metafoo.co.uk> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Richard Smith <richard-llvm at metafoo.co.uk> ---
The new testcase is also rejected by GCC 10 onwards. But it accepts with this
change:

-  if (auto i = GetInstance<X1>())
+  if (auto i = GetInstanceImpl((X1*)nullptr)())

whereas Clang rejects, saying:

<source>:59:16: error: function 'GetInstanceImpl' with deduced return type
cannot be used before it is defined
  if (auto i = GetInstanceImpl((X1*)nullptr)())
               ^

... which gives a suggestion as to what's going wrong. Here's a reduced
testcase:

template<typename X> struct T { friend auto f(X*) {} };
struct X1 { friend auto f(X1*); };
template struct T<X1>;
void g() { f((X1*)nullptr); }

It turns out that when looking for a definition to instantiate in order to
resolve an undeduced return type, we didn't check for the case of a function
for which a different redeclaration was instantiated from a friend definition.

Fixed in dd8297b0669f8e69b03ba40171b195b5acf0f963.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20201031/bf4611a2/attachment.html>


More information about the llvm-bugs mailing list