<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/150340>150340</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang incorrectly allows converting function pointers to and from void* in constant expressions
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:frontend,
constexpr
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
efriedma-quic
</td>
</tr>
</table>
<pre>
Consider:
```
void f();
constexpr auto p1 = (void*)f;
constexpr auto p2 = (void(*)())p1;
```
clang currently accepts, but these should be rejected. [expr.const] says an expression is not a constant expression if it contains a reinterpret_cast ... and converting a function pointer to an object pointer requires a reinterpret_cast.
gcc rejects, MSVC accepts p1.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJxsUsFu4zgM_Rr5QtSwKSuJDz6kCXLb0wJ7XcgS7WihSK5EZ6d_P5CTzrSDAgIEkI-PfHzUObs5EA1CvQp1rvTK15gGmpIje9Mvb6sz1Rjt-3CKITtLScijaLa3a56vOd6jszAJPAjshXwVzdHEkJl-LAn0yhGWFoQ8g8BDgQo8Cuyn75H4FXl4gJ_c2C_to-xz-8LidZjBrClRYP8O2hhaOAs8wbgy8JUyQb7G1VsYCRL9R4bJ1iDUa2leb2MIdYas3zPoACVKObsYwGUIkUHDBtKBvyQncFwyrF3IoCGRC0xpScT_Gp0Z6roGHWzB3CmxCzNomNZguNQvcYMDx9I1jmWwX8FEb6tL9B1t_RA-G_NUs4n96-9_Th_iYWnryg7S9rLXFQ3tXknZYqd21XWQaiexM61qOpK4s61Rqhmxs9QrezBUuQEbVM0eJcq2a3e1bHe9VK2R096afadF19BNO197f7_VMc2Vy3mloVWN7JrK65F83g4LcbNHyOOUYmAKViAKPJXEh_slos5VGgrby7jOWXSNd5nzb3527Gl4WO2CiSmR2cz2Pv6fP-_3z-3mx3otTCne4HmD4MJ3juZqTX64Mi-5HDteBF5mx9d1rE28CbyUeZ7fy5Ji2b3AyyY-C7w89d8H_BkAAP__BTAZ2Q">