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

    <tr>
        <th>Summary</th>
        <td>
            consteval function's argument cannot be used in call to another consteval function
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            c++20
      </td>
    </tr>

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

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

<pre>
    [Godbolt link](https://godbolt.org/z/qre1GKo66)

The following snippet does not compile with Clang (trunk), but does with MSVC and GCC:
```c++
template<unsigned int N>
consteval int inner(char const (&str)[N]) {
    return str[0];
}

template<unsigned int N>
consteval int func(char const (&str)[N]) {
    auto val = inner(str);
    return val;
}

auto var = func("test");
```

```
<source>:8:16: error: call to consteval function 'inner<5U>' is not a constant expression
    auto val = inner(str);
               ^
<source>:12:12: note: in instantiation of function template specialization 'func<5U>' requested here
auto var = func("test");
           ^
<source>:8:22: note: function parameter 'str' with unknown value cannot be used in a constant expression
    auto val = inner(str);
                     ^
<source>:7:33: note: declared here
consteval int func(char const (&str)[N]) {
```

The issue can be worked around by making `inner` `constexpr` instead of `consteval`.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy1VUtz2yAQ_jXowtQjQSRZBx1iOcmh01z6uCNpZdNgUADFTX99F2QnzqOdejrVIJBg2f32Y3dpTf9Yk3x1Y_rWKE-V1HckXxO23Ho_OsIvCbvGtpnXF8Zu8O8nvvcWspuPpigIq0i6Junl3H_ZAh2MUmYv9YY6LccRPO0NOKqNp53ZjVIB3Uu_pY0SKIPGvJ3QLipiDW2ng3gU-fT5W0OF7ulN0wQ0s6UinVtH2Cq0OOthNyrhgfBm0k5uNPRUak9vCb-aJTqjnYcHoeK81BosGu-2wtK4FKAQVjhvA5Z8dRupqCgpDyYoPhb8ZDUNQvkqDRL8sErK9SkT5-IZJt2dD0dM3tCggvD1k0uHLfwtbJT8Hd6DJhs1HcAQxjw4j8Opvif-T7e_nuSNM5PtIHjLL5f4ZgV2FKw1Nnx0QimKJp9ZCEa9NBodL2dXeJN_DQpYSeUcQGKWF0gY_BgtOIcbzqfj5CH51buQM3bsgmEIo9TYonEpIlAzPIM-njd1I3RSKPlTHJ2JbJ74YuF-QloxILZg4Vz6_wJ7oJu9gP4EcxRW7MCDDcAiM-WcapiC2uxjiEyAp6MD3S3QycXA_Q_M_9mHEl_OT33ooVPCvmDtX1Po3VAONUw6N7MQKNgbe4dmhTUTlqL2ke7EXShvuG_2tEjD9wwGuQn_IVBA9CFEnpZC9hXpIoE6K4qU8YpznvQ17yteicRLr6B-mw7hnND2ZtoB-vj2YI6JJHAemXknoZLJqvpVRccjn9oF1mP8UerhOHwYrfkOHcbcdaTA4UdeplWRbOtlV_T5wIZh2ZeiZAzKi7assrLrANKqgkSJFpQLFwqG7KE4szSEb75OZM1SxtJllmUlz3m6KIeOX_BC8GHgPctbcpHCTki1CDjCVZPYOkJqp43DRSWdd8-LwsWiCtEc6scA3Bpbr8B6gRcLGgz46wj-F7omEbE">