<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/54717>54717</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Clang-cl has inconsistent behavior compared to MSVC for __declspec(dllexport) template specialization
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          EAirPeter
      </td>
    </tr>
</table>

<pre>
    A short reproduction of this issue is given below.
```cpp
// foo.cpp

template<class>
struct Foo
{
    __declspec(dllexport) void Bar();
};

template<>
void Foo<int>::Bar() {}

#include <windows.h>

BOOL WINAPI DllMain(HINSTANCE, DWORD, LPVOID) { return TRUE; }
```
When compiled with `clang-cl foo.cpp /link /dll /out:foo.dll`, I get no exported symbols from `foo.dll` (by running `dumpbin /exports foo.dll`), which would result in further link errors in our code base.
While there is a `?Bar@?$Foo@H@@QEAAXXZ` entry in exports with `cl foo.cpp /link /dll /out:foo.dll`.

My clang version is `13.0.1`.

Hopefully LLVM can get this resolved.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyVVEtvozAQ_jVwGRURQx4cOJCXGilpum23rfZSGXDAu46NbJNs9tfvGEpT9bDSIguPPfY3M994JlflJc3A1Epb0KzRqmwLy5UEdQBbcwPcmJbhHyp-YhJyJtQ58MKlF2beJOxH0TTvO2SNAw5KBde97m_ZsRHUMi9aFIIa40WrXmGsRouwVur9-HTeC4Df21vJCmEaVnhkVgrBfjfoqEcSOClewpxq3MelF82H28ur_NXwh83usrMYLbi0bjvKcHzAgXMCkT7BeCTishBtyQBvnbks1dkE9Qdk_5_v91t42dxl9xtYCrGjXCLi7ebu8Sm7W6w8soDly_5h6YTt_fN-s3y3htzbVkt4eviOzszhan3guF--1JiDQh0bLlgJZ25rcPwLKqubQgzEAyZBcPnLzciam1SLcWZOjxsODj3YQMUsSAU9rQhoLsdcCQMHrY4O-HoeMWb5BXQrJZeV05Xtscm5dOD9fQOf4RNn4VzzooazakWJEZpWWMAbh1bbmmnoXGRaK23ctmo1hoYE59SwYIgXAwV3unuD1Bn2orXLVOwEj8Quj3F469Zx-G2VZa-vP5zDTFp9cbiDd1e2_oOn4HN6dxfoqIYT08YVCbqEZ0ZREAajr4dvVcMOrRAX2G6fd1BQ2dHdFRVyocSJlYFfplGZRAn1LbeCpYshkzV1nBRKGm4shoKFV9MTV7rLPtWYLKtg9_i8wGD0PwpleP_glJwK_oe6-vZbLdLa2sa4t9-VbYX8tHmA-I4WcRqmG-wKP1mBaOuuGRgUxvF0NPXrdFawhI1IHoVxRMuYRCwMi5BOyDQnURxNfEGxY5jUG889QiQ79_0EZW-89HlKQkLCOCQjEifRJAhpPi6SAy1mSYwfwYyyI-UicH4ESle-TjuX8rYyqBRIjrkqsa_wSjLWmUN82lpsbOkq4_qeWab9znjaOf8XKRmIBQ">