<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/157103>157103</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang] Valid constexpr noexcept expression with explicit lambda return type is rejected
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
TheAliceBaskerville
</td>
</tr>
</table>
<pre>
[Godbolt Demo](https://godbolt.org/z/4x4KEGxeP)
Clang version: 22.0.0git
#### Reproducer:
`clang test.cpp`
`test.cpp`:
```cpp
template<typename>
constexpr void bar() noexcept([]<typename...>() -> bool { return true; }()) {}
int main() {
bar<void>();
}
```
#### Clang output:
```
test.cpp:2:31: error: noexcept specifier argument is not a constant expression
2 | constexpr void bar() noexcept([]<typename...>() -> bool { return true; }()) {}
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test.cpp:2:16: note: in instantiation of exception specification for 'bar<void>' requested here
2 | constexpr void bar() noexcept([]<typename...>() -> bool { return true; }()) {}
| ^
test.cpp:5:5: note: in instantiation of function template specialization 'bar<void>' requested here
5 | bar<void>();
| ^
test.cpp:2:31: note: undefined function 'operator()<>' cannot be used in a constant expression
2 | constexpr void bar() noexcept([]<typename...>() -> bool { return true; }()) {}
| ^
test.cpp:2:31: note: declared here
```
#### Expected behavior:
Successfully produces essentially empty executable.
#### Environment:
```
clang version 22.0.0git (https://github.com/llvm/llvm-project.git 779868de6975f6fd0ea17bb9a8e929037d3752d7)
Target: x86_64-w64-windows-gnu
Thread model: posix
```
#### Notes:
Removing `-> bool` results in successful compilation:
```cpp
template<typename>
constexpr void bar() noexcept([]<typename...>() /*-> bool*/ { return true; }()) {}
int main() {
bar<void>();
}
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzUlt-P46YTwP8a8jJai-Bg4oc8eHeTe_hKX1XXU18rDJOEKwYXc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