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

    <tr>
        <th>Summary</th>
        <td>
            [clang++] Template type alias introduces new type
        </td>
    </tr>

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

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

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

<pre>
    When implementing a Scott Meyers singleton with a templated class requiring a template template argument, the singleton is instantiated multiple times, at different memory locations, despite the type arguments being identical, except that one version uses a template type alias.

# Affected Versions

clang 13, 14, 15, 16, 17

# Source Code

```cpp
// code.cpp
#include <iostream>
template <typename T>
class B {};
template <template <typename> class ShmConcept>
class A {
   public:
    static void* get_instance() {
        static A a;
        return &a;
    }
};
template <typename T>
using Alias = B<T>;

int main() {
    auto a1 = A<B>::get_instance();
    auto a2 = A<Alias>::get_instance();
    if (a1 != a2) {
        std::cout << "Should have the same address but : " << std::hex << a1
                  << " != " << a2 << std::endl;
 }
}
```

# Compile Command And Output

```sh
clang++ code.cpp
./a.out

Should have the same address but : 0x55ff4a4c2049 != 0x55ff4a4c204a
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVU1v4zgM_TXKhZhAluI4OfjgpJPbYg8d7B4XikTHWsiS16I67b9fyG4-3HaACQIlIPkeH0nRVjHai0esWXlg5dNKJerCWKNr0Q-2bVfnYN7qvzv0YPvBYY-erL-AgmcdiOAPfMMxQrT-4pCCh5-WOlBA2A9OERrQTsUII_6X7Dgjr777HzVeUmZm4gjU4QOdjWB9JOXJTmx9cmQHh0C2x5jjFYGxbYsjeoIe-zC-gQtakQ1-CjAYB5uzdQj0NtyzRThjVmRNLkorl6PxVeNAQJ0iCB7hBcdog4cUMS60T0zOqrhm_Inx5v0UEpq2RZ3F_jVj42OAdspfoJA5V7GZznI6t9NZfSR7DmnUCMdgcOHa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