<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63117>63117</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang cannot compute at compile time `typeid` of a variable of concrete class type with vtable
</td>
</tr>
<tr>
<th>Labels</th>
<td>
c++20,
clang:frontend
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ilya-biryukov
</td>
</tr>
</table>
<pre>
On this code:
```cpp
// Build with -std=c++20
#include <typeinfo>
struct base { virtual void enable_vtable(); };
struct derived : base {};
derived d;
static_assert(&typeid(d) == &typeid(derived));
```
Clang produces the following error:
```
error: static assertion expression is not an integral constant expression
note: typeid applied to object 'd' whose dynamic type is not constant
```
Even though `typeid` can be computed at compile time (since `d` is not a reference and has a concrete object type).
GCC and MSVC compile this code with no errors, see [godbolt](https://gcc.godbolt.org/z/4aKW1WaKv).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxsU8mO4zYQ_ZrSpdCGTGqxDzq07XEOgyCHAJnjgCJLEhOaFEhKHefrA4r2dM8CCJLI2l7VeyVC0KMl6qA-QX0pxBIn5ztt7uKl1_6-_OPWonfq3v1hMU46oHSKgL9CeYHyFZoyP3KeHzfsCuyKp0UbhW86TvgSogJ-kcBOwE6sfPpxbaVZFCHwc7zPpO3ggH96mLd3iH6REXsRCKE94ap9XITB1WmFZEVv6Osa0wfYAdgR-AmhvQA_fRevyOuVFAJ__Zbro1t-P73Uh3ARtfwqQiAftwrNBlQBOyhgRwR-AX7B7-5zlgRmw_PDnPLxbIQdcfZOLZICxolwcMa4N21HJO-d_3nC-fg0YsaGGZt2Funf2VMI6VcHtC6isKhtpNELg9LZEIWNH9xyQutiohNzAyjm2WhSGB26_m-SEYG1CliLb5MLhOpuxU3Lzf1Z55n7l4A_rZSE45ZxQmjKx5yaEqWw2BNKd5uXSApF3P61IYz6RgjsELSVlKK2gGdX6GkgT8kkrMJJBBQJg_QU6Yk61QF23GUQv53Pm-_vf_51fq_yVHOWqXV58gHYGQMRQn0aneqdiVBfgB2mGOeQeNkUPkq5e5h3zo_Arv8Bu1bi85f9F_F5TbUL1XF15EdRULdvDvWxrfa8LaZONH0rK95zdqzqw8Dqpqm5qNlASh5F2xS6YyXjZVPW-6o81GynGqKB16KqGqXUUEFV0k1oszNmvaX6hQ5hoa7h-31bGNGTCdtKM_a-d4wBO6ebpD7gr4N3NpJVyVBfCt-lZC_9MgaoSqNDDO_po46GuqxbKWymfWPuZ-I-suwGFLgKr9OSptM3oqQRIWQdbfPPe1ws3nQ_TFrHael30t2AXROgx-dl9i5xDey6NR-AXbf-_w8AAP__9AuFBw">