| Issue |
174514
|
| Summary |
Presence of trailing return type in lambda template defined within function template disables constexpr operator()
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
dgodfrey206
|
When I define a lambda template within a function template and give it a trailing return type I'm not able to initialize a constexpr variable with the result of calling the lambda. If I remove the trailing return type or make the enclosing function a non-template it works. Tested with Clang trunk with `-std=c++26`. Compiles on GCC trunk. https://godbolt.org/z/vT9WP5hz5
```cpp
template<class>
void foo() {
constexpr auto bar = []<class T>(T) -> int {
return 0;
};
constexpr auto result = bar(0);
}
int main() {
foo<int>();
}
```
Error:
```
error: constexpr variable 'result' must be initialized by a constant _expression_
8 | [[maybe_unused]] constexpr auto result = bar(0);
note: undefined function 'operator()<int>' cannot be used in a constant _expression_
8 | [[maybe_unused]] constexpr auto result = bar(0);
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs