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

    <tr>
        <th>Summary</th>
        <td>
            [BUG] Template type requirement
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

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

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

<pre>
    Today playing with mac os compiling and clang 9.0. And apperntly i noticed a bug in it.

Normally when you create a template like this:
example.cpp

```
template<typename T>
void execute(T v)
{
    /* Your code */
}
```

Because execute isnt been used anywhere in the example.cpp this means this function wont get compiled. You have to define it in your cpp file on the bottom the following code to get it compiled:

```
template void execute<int>(int v);
```

Now we have a basic understanding what is required we can go to the clang bug.
When you create a class constructor. It wont return any type. This means at the end of a function it doesn't have a type. When you declare the template type as before you see we have a void as a return value. And in clang 9.0 it has a type as requirement. And this shouldn't be happening.

The following will fail in clang 9.0 but it should be valid

```
template CPubKey::CPubKey<unsigned char*>(unsigned char*, unsigned char*);
```

Error clang++ gives:
```
src/cpubkey.cpp:261:20: fatal error: qualified reference to 'CPubKey' is a constructor name rather than a type in this context
```

I had a discussion on the discord channel[1][2] about this bug a year ago and looks like it didnt got fixed in the latest version.
In this discussion someone made a example code over here[3]. It clearnly shows that GCC is accepting this as valid and clang doesn't.

The main issue is that clang expect a type return before the function name. But as we know is that a class constructor doesnt use a type return.

Reference:
[1] https://discord.gg/DgjWY7DK
[2] https://discord.com/channels/636084430946959380/636808521371090956/850316658605293578
[3] https://godbolt.org/z/o39MahhKz
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVl1v2zoS_TX0y6CGTFm29eCHOK6LoLvFYpFF0ccROZbYUKTKDzvur1-Qkp2k6e29QKBINDlz5syZI6H3qjVEW1btWLWfYQydddsH7P8VBztrrLxsH63ECwwaL8q0cFahgx4FWA_C9oPSaRW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