<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/64119>64119</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang allows returning pointers to stack memory in constant functions
</td>
</tr>
<tr>
<th>Labels</th>
<td>
c++20,
accepts-invalid,
consteval
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
tbaederr
</td>
</tr>
</table>
<pre>
See: https://godbolt.org/z/r1vf1Meod
```c++
consteval const int *gimme() {
int p = 0;
return &p;
}
#if defined(__clang__)
static_assert(gimme() != nullptr);
#else
static_assert(gimme() == nullptr);
#endif
```
Clang seems to return something that is no `nullptr`, while GCC seems to return `nullptr`. But as discussed in https://reviews.llvm.org/D154795, they should both reject this program.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMU9GOqzgM_RrzYk0VTIHywEOnVfdpn_YDqgAGshsSlJiOZr_-CqbT25krXV0pAuTYPsfnGB2jGRxzDfkr5OdELzL6UEujueMQksZ37_U_zJAdcRSZI2RHoAvQZfBd463sfBiALv8DXUJ669O_2XegzqCO92ehPk4L9Lqep7vWuyh80xa3LzROEOg4mGlioANQhVDeKxBxu58RsjMqyJ7igWUJDoGK-RGH8vyFBmWmx45747gDOlyvrdVuuF6Bqo-MKFpMe9UxchCgwxcWlK6obrF2lrCWPGAoYxv5D1pk59-0cJ3pv-n1zP60csXIPEUU_zlv9BPLaNyAMmpBE9F5hEJ9YhQK6IRvo7GMf51Ov9R_Sd3h6yKoI3YmtkuM3KFx3ywPfDP8FnfW3qa77-c035dVvgLJyO8YR7_YDhsvIwb-l1tBGU3EOfgh6Gn3PFXS1VlXZZVOuE6LSmV5WSlKxjpTTVGmuiop0z03OqVmz1WV96rRfXeoElOTokyVVKgyT_e0aw86zVTDfcF86A8a9oonbeyDamJiXLgu9mlaJVY3bOO28kT3vSQFREAnINJty7PEF-Nu2pruEX-s6xrJz0mo1-4vzTJE2CtrovyUJhEjlusP47S1_i3eZV_9mr1xwmEzI4pu_8OJJx_eV8k3FO0E-8W1YryLyRJs_e3nMzIuza71E9Blxby_XubgV9GBLtvAEeiyzfwjAAD__xstMfU">