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

    <tr>
        <th>Summary</th>
        <td>
            Global templated variable is not defined
        </td>
    </tr>

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

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

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

<pre>
    Tested Clang Version: 17.0.3
Platform: Windows
C++ version: 20

Clang for Windows will create an executable that crashes while executing the last line of this code :
```c++
#include <iostream>
#include <typeindex>


template<typename T>
const std::type_index type = typeid(T);

const std::type_index type_int_hard = typeid(int);

const std::type_index type_int_templated = type<int>;

int main(int, char**) {
    std::cout << "Local version: " << type<int>.name() << std::endl;
    std::cout << "Global hard version: " << type_int_hard.name() << std::endl;
    std::cout << "Global templated version: " << type_int_templated.name() << std::endl;
}
```
In fact the variable `type_int_templated` has zero binary data.

It seems that it is not possible to use a templated global variable in the definition of another global variable.

However this code runs perfectly with Mingw for Windows and also GCC and Clang for Linux. Moreover this code appears to be in agreement with this article: https://en.cppreference.com/w/cpp/language/initialization
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVU2PpDYQ_TXuS2kRGLqhDxxmetKblXaVHFbJcVXYBTgyNrKL6Zn99RHQ0x-7ySaKIqFuoJ7fq3rlwhij6RxRLbaPYvu0wYl7H-pfosKgfcC4abx-rT9TZNJwsOg6-I1CNN6J_AGyMkmTXKRPIn341SK3Pgzz-9-N0_4U18BByEchH-H5uk6ma-gMWGhbH97WwclYCyoQMgE6oBdSE2NjCbhHBhUw9hTh1BtL56hxHXBPYDEyWOMIfAvcmwjKawKRn8XELl0vtaZ1fitz45SdFuTB-MiBcBD5T38V5teRjNP0co3f_DINo0WmM9DhQPD5glTeRYbIek4of5gRXxYumG9B5E_LjdFCVp-F3Iv88Zb8x8u_GMdfegz6nsc4_k9Mb5Vc6WZvHM_F3JMZxzCgcW9iB1A9BiEflmsPojzDAeCqqfzEs58iP4CQ8qNXaG93iZDyLXwnnsyeClktzGv8wklO20tyP1J7b32DFha3_l7z4uj_qXn19R-EL8B_rS7Kp2-2-fr4wUGLipcJecZgllkSu_R7KbFLoccIXyl4aIzD8AoaGZPbfn9giERDXMfRMJgIzjOMPkazjKmHKRLgTa3dWvxF3bglG02tcYaNd_PAovPcU_gWfCf-sz_RM4Wb4Q6TizBSaEmxfYWT4R4-Gded7j4q6DSgjR7eHw7Lw_W789G46SWBTz6Qv6fGcSQMcS6oWXLGLhAN5HiVWZAY2ChLcxt75jHOjZFHIY_kEjWOgVoK5BQlyg9CHk9CHtU4CnmcE5iwIyGPiwlozVecvdjoOtf7fI8bqrMyk_t9VWbVpq9l2ezaLM2KRmVYbdMt7UpZtEWWbTOpi3RjapnKIi2yPK22VV4lW12VBe3LQrdZ2WoSRUoDGptY-zwkPnQbE-NEdVXt0u3GYkM2LseBlI5OsASFlPPpEOp5zbtm6qIoUmsixysLG7ZUf7_FL_1et8jSb9KbKdj63qzOcD81Z49m2vPfuzH4P0jxbNKcTBTyuCT7ZwAAAP__m5Yelw">