<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63242>63242</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang frontend C++ crash on invalid code when using `typeid`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
brutalsavage
</td>
</tr>
</table>
<pre>
To quickly reproduce: https://gcc.godbolt.org/z/Ens9e5xnn
```cpp
#include <type_traits>
#include <typeinfo>
struct scoped {
enum class scoped2 {
RED,
YELLOW,
GREEN
};
};
template<auto N>
struct scoped_struct {
void f() {
class scoped2 e = scoped::scoped2::RED;
typeid(e); //remove this = no crash
}
};
int main() {
constexpr scoped_struct<scoped::scoped2::RED> s{};
s.f();
}
```
Compiling the above invalid code crashes clang `clang++ -x c++ -std=c++23`, crashes locally using clang-17.0 (a10019a), also on trunk (see godbolt link)
Note: removing the `typeid(e);` leads to no crash.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VEFv4zgP_TX0hWggU4kdH3xonOS7DPoBgwUWexrIMptoq0heS860--sXcjxt3GI3CGSJlEi-90SpEMzJMdew2cFmn6kxnv1Qt8MYlQ3qqk6ctb57q3_z-Ndo9It9w4H7wXejZpCPeI6xDyAfgY5Ax5PWq5PvWm_jyg8noOPfQMeDCxVvXp1DEHsQj_NYiNtf9_1sIWmctmPHCLKJbz3_iIMyMYA8_NsO4579h3saQxxGHTFo33OHUO5uZkREduMFtVUhzG5a-tPv-2EP1Cxtfxy-ffv_71_M__t-ODzNJij3IOdQ9_PIl96qyCAbNUaPT-_VLur8Ma8W5Vy96fAZaAtU3XmWABIV-3mVhJCPs-e2SHDkJ4gTcR3QloEqkDu8qTfwxV8Z49mEKabzqAcVzh-HE7AvCI2LeFHGfakTEbV3IfJrPyxhgmz-u-ADhhTnLguG1czEgublVbq_Bo2_9MYad8J4ZlRtgmbcVVnTofYd37BxSHS6E6aLmCZAO6AdPryi_jUNsQO5n5ckUx5q3o9br5W1bziGlGuK8ZCXK4FAW5ULkVcqFU0NKhs8eodxGN1LcgdmnNsFrXEvad8dgicfpx6bdPkFBArxWT4oBFpWXcDo30VbLXptGrOull0lK5VxnRfbYi03IqfsXFeqU20pnzcF6bKSLITWa6XX1boti5x1ZmoSJEWRC6Jc5LQqhVYt07asBCsqNawFX5SxK2uvl9T6mQlh5LqQtKbMqpZtmN4YIsc_cXICUXpyhjqdeWjHU4C1sCbE8BElmmi5biaFngfvIrsOm1mYCWcidCHrzzO7WYwPrgqB2TjY-tNzZeJ5bFfaX4COKef8eegH_yfrCHScKg1AxwnJPwEAAP__l5iC1g">