<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/96191>96191</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang][trunk] compiler crashes if the first parameter of a member operator delete is in class type
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Snape3058
</td>
</tr>
</table>
<pre>
[detailed execution result on godbolt](https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(filename:'1',fontScale:15,fontUsePx:'0',j:1,lang:c%2B%2B,selection:(endColumn:29,endLineNumber:6,positionColumn:29,positionLineNumber:6,selectionStartColumn:29,selectionStartLineNumber:6,startColumn:29,startLineNumber:6),source:'struct+S+%7B%7D%3B%0Astruct+T+%7B%0A++void+operator+delete(S)+%7B%7D%0A%7D%3B%0A%0Avoid+foo(T+*t)+%7B+delete+t%3B+%7D'),l:'5',n:'0',o:'C%2B%2B+source+%231',t:'0')),k:49.56256362285746,l:'4',m:100,n:'0',o:'',s:0,t:'0'),(g:!((h:executor,i:(argsPanelShown:'1',compilationPanelShown:'0',compiler:clang_trunk,compilerName:'',compilerOutShown:'0',execArgs:'',execStdin:'',fontScale:14,fontUsePx:'0',j:1,lang:c%2B%2B,libs:!(),options:'-std%3Dc%2B%2B20',overrides:!(),runtimeTools:!(),source:1,stdinPanelShown:'1',wrap:'1'),l:'5',n:'0',o:'Executor+x86-64+clang+(trunk)+(C%2B%2B,+Editor+%231)',t:'0')),header:(),k:50.41112058766887,l:'4',n:'0',o:'',s:0,t:'0')),l:'2',n:'0',o:'',t:'0')),version:4)
This bug was discovered when I was studying the usage of `std::destorying_delete_t`.
After removing the first parameter of a pointer type, the compiler crashes.
In the example below, `std::destorying_delete_t` is simplified to `struct S` for the sake of debugging.
```cpp
struct S {};
struct T {
void operator delete(S) {}
};
void foo(T *t) { delete t; }
```
Pretty stack dump:
```
1. <source>:6:26: current parser token ';'
2. <source>:6:16: parsing function body 'foo'
3. <source>:6:16: in compound statement ('{}')
```
Crashed in function `clang::Sema::ActOnCXXDelete(clang::SourceLocation, bool, bool, clang::Expr*)`
when checking QualType `ParamType`, which is not a pointer and its `getPointeeType` returns an empty QualType.
https://github.com/llvm/llvm-project/blob/724d903e03aaf7ee7d4bcdf3cd9fe1e1bda33f9a/clang/lib/Sema/SemaExprCXX.cpp#L3883-L3884
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVluP6ygS_jXkBXVk4_tDHpykI410NNOr9Er9doRNOWHaBgtwX_79qsDJcfqys3ukFmmK-oq6fFWGWytPCmBDsi3J9is-ubM2m6PiIyRRVq4aLd7xUIDjsgdB4Q3ayUmtqAE79Y5qRU9aNLp3JNsTVp6dGy1JasIOhB3mo7U2Jy9ITv4oJqwkrPx-cyZJ3WoB90I6bQjbSX9adrIHxQfwuyImrCBs12nlji3vURpns-DfFh7egloU1P7GY8J2PVd4V0tYxrbzsrPQQ4txhXtAiZ3upwG3rCJsB0r8kAr-nIYGDEnqnLDdqK1EyK3mRfpJ_XrF0XHjbkG3Z5-hXyC-UvQHejLtnCDrzNQ6wrZH4kMt_LInLEvwv6i-KjwuFKLab7YvWgrCtnoEw30VtgJ6cEBYefR33ZpE2I1xv8xGOq0JK8MttbtBX61u3Yy9mCxCRH0IJgtlVDdF1WG3WxZzO6cgCJKZJW6Jq4LlZ5LUabXOcpblSc5YmRVp_uvGNCAHJE4UfXd32CDnoy-u2X1F7dBFS2Jzc7IPXEF_POtXdUPvVg-j7Dmy46NGtNTwJGiR3T-dmdTz4uDPa8vcAv6a3Gdr6FxtTnYJQNnRCamWwpu-S3-v73rZ2EV2MGF6xFDn6--sE8iK_QLGLvl_AWOkgI8GzKScHOBR6_7j0bU5Yt9CQn5K6Zz0V8PHpeB_5OH9tbDbtzK_y1PCtr4knozlXJdA_vKGtDvCtpdpd-Vt9T11z8CFr_g1NiRzFq3TOI5ZlJVFnp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