<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><span class="vcard"><a class="email" href="mailto:richard-llvm@metafoo.co.uk" title="Richard Smith <richard-llvm@metafoo.co.uk>"> <span class="fn">Richard Smith</span></a>
</span> changed
              <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED INVALID - defined template friend is 'sometimes' not defined - std::experimental::any"
   href="https://llvm.org/bugs/show_bug.cgi?id=27544">bug 27544</a>
        <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">Status</td>
           <td>NEW
           </td>
           <td>RESOLVED
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">CC</td>
           <td>
                
           </td>
           <td>richard-llvm@metafoo.co.uk
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Resolution</td>
           <td>---
           </td>
           <td>INVALID
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED INVALID - defined template friend is 'sometimes' not defined - std::experimental::any"
   href="https://llvm.org/bugs/show_bug.cgi?id=27544#c1">Comment # 1</a>
              on <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED INVALID - defined template friend is 'sometimes' not defined - std::experimental::any"
   href="https://llvm.org/bugs/show_bug.cgi?id=27544">bug 27544</a>
              from <span class="vcard"><a class="email" href="mailto:richard-llvm@metafoo.co.uk" title="Richard Smith <richard-llvm@metafoo.co.uk>"> <span class="fn">Richard Smith</span></a>
</span></b>
        <pre>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.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>