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

    <tr>
        <th>Summary</th>
        <td>
            Returning `static constexpr` variables by reference from `consteval` functions is completely broken
        </td>
    </tr>

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

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

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

<pre>
    Here's a reproducer:
```cpp
#include <iostream>

consteval const auto &bar()
{
    static constexpr auto ret = 42;
    return ret;
}

static_assert(bar() == 42);

int main()
{
 std::cout << bar() << '\n'; // 0
}
```
Notice that the `static_assert` says `bar() == 42`, but if you try to print `bar()` with `cout`, it prints `0`.

Tested on Clang 20 and trunk.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJxsUsFuwzYM_Rr6QjRQqDhODj4k6YKedhh2H2SZTrQqkiHR6fL3g-x06YYBBmiRj4-PxDM5u0tgbqE-Qv1emUmuMbUf0T-O3tjPk5Gqi_2j_eDEQE1Gg4nHFPvJcgJ9AHWArVo-O47lSdoF66eeEfTJxSyJzQ30L6WmDjaGLHw3Huc_NJNEBNp2JgHtgPYF1hxBHRARsxhxdoHyX2Na4IkFQb_jhkB_IxPLlEIJSw6a92XgQvGHyZmTAO3-GVQoniy0fzapgwuCN-PCf8Vk6cu6-mDjVKafQJ_wJ9ecAGqgPoUS9BGBzkBnVC8536cCdfg1irOMcjWCcmWErfq31K3CbB65FP5P81YBnbCbBN2AjzihpAdKxDGVFX42FaYvJ9eSLOqfrU4W7DyhiFotF_ids3CPMeDJm3BBUmhCj5Km8Lmq-lb3e703FbfrptbbzY7WdXVtB2YiO1BdD6R11ymrN7bWttlo6ru1rlxLimrVUENKq3W90rXua971u6E2Zqc3sFF8M86vvL_fVjFdKpfzxO26Vrt6XXnTsc-zUYkCf-FcBaLi29SWprduumTYKO-y5BeNOPHc_jYbxIXL69IvX5UT3U1ypvOcsXtg4oETB8s4pHhbLvc0bsEOU7DiYsjoMtp4Gz0L-wd2KX5yqKbk26vImItlZhNcnFynbmXjDehclD3D25jin2wF6Dzvk4HOz4XvLf0dAAD__1SwFy4">