<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/134820>134820</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Constexpr allocating temporaries in `if constexpr` are rejected.
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          MiroPalmu
      </td>
    </tr>
</table>

<pre>
    Clang fails to compile following while gcc allows it:

https://godbolt.org/z/KcqTdeodx

```cpp
#include <vector>

// ok
static_assert(!std::vector{1,2,3}.empty());

int main() {
    if constexpr(!std::vector{1,2,3}.empty()) {
        return 1;
 }
    return 0;
}
```

Error message:

```
<source>:7:18: error: constexpr if condition is not a constant expression
    7 |     if constexpr(!std::vector{1,2,3}.empty()) {
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.1/../../../../include/c++/15.0.1/bits/alloc_traits.h:614:20: note: allocation performed here was not deallocated
  614 |       { return __a.allocate(__n); }
      |      
```

The same conditional is allowed in `static_assert` but not in `if constexpr`.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVEGP6yYQ_jWTyygWBsdxDj4keetLVamHd48wnti0GFzAu3k99LdX2N7s2772UhWhxDDfDMM3HyND0L0lquFwgcOXnZzj4Hz9s_buF2nGede67lt9NdL2eJfaBIwOlRsnbQjvzhj3pm2Pb0Na90qhTFsBdQRxBpbmEOMU0oo3wJveda0zMXO-B978Abz5Sf3-tSPXPVY4lGydaprSkgttlZk7QhDXV1LReRAvG3YJie43YOcQZdTqJkMgH4FXwPMQu3SuOG9ux0sO_MqBXwUcv2Q0TvHbgjylKS5rUG0jjlLb1YJwTPuIiPqOytkQ6TH5_3DAd5HS8BRnbzFfz0U4ftmMm4FtCS37T1LWFF-8dx5HCkH29CT6E0hcg5u9osSVOB9BnPMKxBkpuaaP51W2e3U6amdRB7Quolzt0kZMGApBO7sleEQ4XvH_ZiTFhMPLn_861nq7KQJvNgX6PT0m4zz5pCyl9sHKKQwuQYxu103gzaMqb2WxN9rOj31vZ-BNfshYlgNvsuzHn01x6SDgl2V-OLQ6BuBNErq6RS91DNkA4lzmBYgzZ4lc62Kqy_IalFyIncjfnR-pw4E84Ztcie5ow1C3UFHmxZPeRMrlXQ-3m8zeocCr282uov1OOfjh-aNmvg6EQY70UWtpUrWXB0sdaotQss-vqGTYznHJczV_KnjJsl1Xi-4kTnJHdX4sipwV4pTvhlpVTJ5K3lW8ExVTVVEe8kNFJFvRFpXgO11zxg-sYBU78VLkmWzlsWsLJu4nIioPUDAapTaZMa9jahc7HcJMdS6KirOdkS2ZsLQtzi294WIFzlMX83Vy2rdzH6BgRocYPsJEHQ3V16f832tke4w0Ts5Lryn884VRekJPv5KK1GW72Zv6b-1Nx2FuM-XGJEHz-v63n7xLXklcKdGkoO0mrzX_KwAA__9wdqs3">