[llvm-bugs] [Bug 27544] defined template friend is 'sometimes' not defined - std::experimental::any

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Apr 27 13:27:20 PDT 2016


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |richard-llvm at metafoo.co.uk
         Resolution|---                         |INVALID

--- Comment #1 from Richard Smith <richard-llvm at metafoo.co.uk> ---
This code is ill-formed.

In order for 'gun<T>' to be parsed as a template-id, there must be a
declaration of a template named 'gun' visible to name lookup, and there is not.

The problem is that GCC's name lookup has a bug where it incorrectly injects
friend function templates into the surrounding scope. Try this:

  struct bar {
    friend void f(int) {}
    template<typename T> friend void g(T) {}
  };
  int main() {
    f(0);
    g(0);
  }

All versions of GCC that I tested reject the call to 'f'.

Versions of GCC prior to 5.0 incorrectly accept the call to 'g'.
GCC 5.x rejects the call to 'g' but produces a bogus typo correction from 'g'
to 'g'. Whatever it's still getting wrong here leads to it accepting your
original testcase.
GCC 6.x properly rejects both calls and your original testcase.

-- 
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/20160427/21bcb5be/attachment.html>


More information about the llvm-bugs mailing list