Issue |
157103
|
Summary |
[clang] Valid constexpr noexcept _expression_ with explicit lambda return type is rejected
|
Labels |
clang
|
Assignees |
|
Reporter |
TheAliceBaskerville
|
[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>();
}
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs