<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/143065>143065</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
ubsan has stopped identifying a mismatch between static and dynamic type of an argument to typeid()
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ojhunt
</td>
</tr>
</table>
<pre>
A post on C++'s std-proposals said some clearly UB code did not trigger a sanitizer failure, which was somewhat confusion, but after investigating it's a regression since clang 20.
```cpp
#include <typeinfo>
struct Foo {
virtual ~Foo(){}
};
struct Bar {
virtual ~Bar(){}
};
int main(int arc, char**) {
Foo f;
Bar *b = reinterpret_cast<Bar*>(&f);
(void)typeid(*b);
return 0;
}
```
Compiling with `-fsanitize=undefined` and running reports an error in 20, but passes in trunk
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJx0U82O8zYMfBrlQmygyLETH3xwki9v0HNBW7TNr7ZkSFSC9NBnL-TsYvfQAgT8Qw41nBExRh4dUaPKiypvO0wy-dD431Nysuu8fTUtrD4KeAdXZS5bnCJEsR9r8KuPOEeIyBaiXwj6mTDML_jjAr23BJYtOC8ggceRAiBEdCz8NwUYkOcUSJkrPCfuJ3hi3Lo8JxTovRtSZO9yvksCOAgFYPegKDyisBuBZWODEGgMFHM5RHZ9JoJuBKP3Src5Kv2Ofl3zpynY9XOyBKq4ymsldoNXxS-l2ygh9QJ370GdLkq3APDgIAln-OfuvTJnZeqcOt1yq9NNFZdv3AXDf-AuGP4Pp3TLTmBBdsqc8yuGPg_dTxnUblF_98zEhjcU4H2caTtQxQ0CsRMKayD5s8coqrhe3j2KX9vx1ZApfGGVOT88W2XqTQG7lbTdz5JAkoID_Un1zfxLyzf5q19WnrMbT5YJVKU_hi-TVXFLztLAjqyqNKCzEJJzuTrQ6oNEQAcUgs_WgtFfbq8YI8X8T0Jyf-1sU9i6qHFHzeF0rA_n8nSodlODdVXb81CUdX3Q9QFN1WNJVB0Rq3M50I4bo02pK13pY1keqn3Xd9WpMHjUQ1fXVaGOmhbkeT_Pj2Xvw7jjGBM1h2Ohq3I3Y0dz3BbEGEdP2LLKmLwvocmgjy6NUR31zFHidxthmalJXUQHU77a4teVLLAlJzy8sggIC8cFpZ-gI3kSOYiCwv0mlX05XLiHbA_4IUuFYUwLOQHx8MO1epfC3Ewia1RFq8xdmfvIMqVu3_tFmXtm9fnIi_ubelHmvs0Slbl_DvtozL8BAAD__-K6RyY">