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

    <tr>
        <th>Summary</th>
        <td>
            [clang] incorrectly tries to capture constexpr variable in lambda with parenthesized noexcept specifier
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

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

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

<pre>
    The following program https://godbolt.org/z/jTdY6d81n:
```
template<typename ...Ts>
void f(Ts...) {}
    
int main (){
    constexpr int n = 42;
 f(n, []() noexcept (true) {});
}
```
is rejected by Clang starting from llvm-17 with 
>  error: variable 'n' cannot be implicitly captured in a lambda with no capture-default specified

which is obviously wrong.

Note that the `noexcept (/* expr */)` is necessary to reproduce this (dropping the `noexcept`, or using just the `noexcept` without a `(/* expr */)` doesn't manifest the bug).

This is very similar to https://github.com/llvm/llvm-project/issues/120503 except that 
 1. The cause in that case seems unrelated to `noexcept`.
 2. That bug was introduced in llvm-16, whereas this bug only happens from llvm-17.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJykVLGO4zgM_RqlIcaQ5SSOCxfemU15VZorZYmxNZAlQ5STzX79gXb2NruHqxYw4ILiI_n4HjWRGwJiKw5fxOFjp5c8xtSaIbisadz10T7ay4hwjd7HuwsDzCkOSU8w5jyTqDqhzkKdh2j76HMR0yDU-btQ58-L_ftoT2XgN7ITR_n8ZJdxmr3OKKr3_Jgx6AmhKIoLieqrkN0tOgtXoU4XKopCqAZE_UXUH0J2AABCdi5kmLQLINRJqIbDW8zEQBm_zQn4SQBRfcBeiWqNM2QQ6h22YbdcCBG_GZwzY-W04Es91WyZW-3XCRxBwk80GS30D3j3OgxAWafMFF1TnMD72_RW1nB3eeSeRfUVAFOKSVQd3HRyuvcIQtVBqBqMDiFm6BHcNHtnXPYPMHrOS0ILLoAGr6fe6g0wxB_BN4tXvfgMNKNxV4eWi8nuPjozgiOI_c3FhfwD7imGodjCf8WMkEedIY8I4ihfeVh32sFKpFDbihtxlAwX0CCRTg_IERLOKdrFMJQjTrUpzjOT8Bss86beISZYiMOfC_2nNFfg6eKSQcOa8f-t2IjEzLESgrviE65fBqGa55AXbsoR3DA9gNzkvE7c9m_adXlc-sLESagzr-35e5tT5B0LdXZEC5JQ51LJg6zgSdXKH0urLIBdYvRCyMtaA0YTAiFOBEtIyIq3XP3XiblVUJyvM3cPd02s3o3XdfWblI7M333EhJo2uvl1DP4Bo55nDPSL8IqdbSvbVI3eYVvW1bGu631V7sb2KntrrT3WzeGApT7VNVa2lo1t9n1tTmbnWiXVQZZlVe5LWcmil02jm2ZvUdWqxErsJU7a-YJrsed3K0FtqVRdyp3XPXpab4pShr0hlOLzktq1uX4ZSOyld5TpJ0R22a-HaMs4fIALJqaEhq2Qk0Ni9p6yf7H6v15iql48MuuEIY9I7jvanz7_4ZO0W5Jv_0QK67C3Vv0TAAD__9Rlrt8">