<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - C++11 attributes not accepted in template explicit instantiation"
   href="https://llvm.org/bugs/show_bug.cgi?id=29094">29094</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>C++11 attributes not accepted in template explicit instantiation
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.8
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++11
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>matthew.woehlke@kitware.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Clang rejects the following code, with the error "an attribute list cannot
appear here":

  template <typename T>
  T foo(T) { return 0; }

  template [[gnu::visibility("default")]]
  int foo<int>(int);

Live example:
<a href="https://gcc.godbolt.org/#compilers:!((compiler:clang380,options:'-std%3Dc%2B%2B11',source:'template+%3Ctypename+T%3E%0AT+foo(T)+%7B+return+0%3B+%7D%0A%0Atemplate+%5B%5Bgnu::visibility(%22default%22)%5D%5D%0Aint+foo%3Cint%3E(int)%3B%0A')),filterAsm:(commentOnly:!t,directives:!t,labels:!t),version:3">https://gcc.godbolt.org/#compilers:!((compiler:clang380,options:'-std%3Dc%2B%2B11',source:'template+%3Ctypename+T%3E%0AT+foo(T)+%7B+return+0%3B+%7D%0A%0Atemplate+%5B%5Bgnu::visibility(%22default%22)%5D%5D%0Aint+foo%3Cint%3E(int)%3B%0A')),filterAsm:(commentOnly:!t,directives:!t,labels:!t),version:3</a>

GCC accepts this code. As I read N4606 [A.6] and [A.12], this should be
accepted as:

  <explicit-instantiation> -->
  [extern] template <declaration> -->
  [extern] template <nodeclspec-function-declaration> -->
  [extern] template [<attribute-specifier-seq>] <declarator> ;

Moreover, there doesn't seem to be any manner in which Clang accepts an
attribute on an explicit instantiation, which seems surely not intended. Also,
the old style attribute, `__attribute__((visibility("default")))`, is accepted.</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>