<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62467>62467</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Casts from `const void *` in a constant expression sometimes produce the wrong diagnostic
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:diagnostics
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
tbaederr
</td>
</tr>
</table>
<pre>
See: https://godbolt.org/z/M5PdG83Ks
```c++
constexpr bool f(const int *p) {
return (int*)p;
}
static_assert(f((const void *)nullptr));
```
This code produces the following diagnostic:
```console
<source>:6:15: error: no matching function for call to 'f'
static_assert(f((const void *)nullptr));
^
<source>:2:16: note: candidate function not viable: cannot convert argument of incomplete type 'const void *' to 'const int *' for 1st argument
constexpr bool f(const int *p) {
^
1 error generated.
```
Which... makes no sense? "Incomplete type void *"?
GCC manages to produce the diagnostic I expected to see.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVE2L5DYQ_TXlS7HGLXX74-BD78x6WUIgkECOQZbKthJZMlJ5dje_Pqi7Z3pmWHIIaUTbPJef3yu9kkrJzp6oh9NHOD0WauclxJ5HRYZiLMZgvve_EoE848K8JZBnEAOIYQ5mDI7LEGcQw98ghp9Pv5jPrfwpQfUI1fn2X1fXpUF8zOuC6uAT07ct4hiCwwlEe4HQekYQ5w1Eh9DcqhEj8R49gmitZxBnEN0G8vYYmsfXX0ys2Oo_VEoUGUSbyV_4n4I1eCXwu3MbRxBdXi9kz3pfU_622IQ6GMItBrNrSsgL4RScC1-tn9FYNfuQ2Orcnx_aDz4FR3iD5UMKe9QE8hPIcw3yfDjlHlOMIeYbH3BVrJfMPu1esw0epxBRK-eQA4JoJhDN_-EZ4fTph7pE1lVf5fAlA1p5Y41iuovygfHJqtE9F2RAB_9EkVHFeV_JM4YJrddh3RwxIX_fKDt4L7C5OXsThgxn54d05_tvMXrzezF9uHYdZ_IUFZMp_yUKvy9WL2VZ4qr-opS3KZFPBHJAEOLLO4t3ZwLkcGX4_PCAq_JqzikKz4m6BOoeI_yC9G0jzWRyUSIqC9NL08lOFdQf6la0zakWXbH0rVbdYTwINcmu02I6dPJopJbV2NBJ6LawvaiErI6yOjSiqbryWNfT1E7akDyayVRwrGhV1pXOPa15ogub0k59LY51Uzg1kkuXE0II7ZSfQZ7vUlM2d3osYp_f_jDuc4Jj5WzidOdjy476B5U44RTDireReLX5dYXWo8ILrDznBkRKKWcshZXYrpTetOtrDG9mr9ij69-dUpaXfSx1WEEMWc3t8mGL4U_SDGK4WE0ghovbfwIAAP__To2Npw">