<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - Clang accepts explicit specialization in class definition"
   href="https://bugs.llvm.org/show_bug.cgi?id=46728">46728</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang accepts explicit specialization in class definition
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </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>Frontend
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>haoxintu@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Hi, all.

This code, test.cc, is an invalid code I guess, but Clang accepts this without
any diagnostic message.

$cat test.cc
class A {
    template <class> void F(){};
    template <> void F<int>(); 
};

I think explicit specialization shouldn't exist in a class definition.

While in other compilers:

Output in GCC:
test.cc:3:15: error: explicit specialization in non-namespace scope 'class A'
    3 |     template <> void F<int>();
      |               ^
test.cc:3:22: error: template-id 'F<int>' in declaration of primary template
    3 |     template <> void F<int>();
      |                      ^~~~~~

Output in ICC:
test.cc: error: explicit specialization is not allowed in the current scope
      template <> void F<int>(); 
      ^

Noted that this issue only happens in Clang-7 and onwards version, while other
version upwards Clang-6 rejects this with "error: explicit specialization of
'F' in class scope".

Thanks,
Haoxin</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>