Issue |
125914
|
Summary |
Entire lambda body is printed in a note
|
Labels |
new issue
|
Assignees |
|
Reporter |
Endilll
|
Consider the following example (https://godbolt.org/z/P7dqa81bG):
```cpp
class S {
class Incomplete;
struct Inner {
consteval void fn() {
Incomplete i;
}
};
static constexpr int r = [] {
Inner{}.fn();
return 0;
}();
class Incomplete {};
};
```
We issue the following diagnostics for it:
```
<source>:10:28: error: call to immediate function 'S::(anonymous class)::operator()' is not a constant _expression_
10 | static constexpr int r = [] {
| ^
<source>:11:13: note: undefined function 'fn' cannot be used in a constant _expression_
11 | Inner{}.fn();
| ^
<source>:10:28: note: in call to '[] {
Inner{}.fn();
return 0;
}.operator()()'
10 | static constexpr int r = [] {
| ^~~~
11 | Inner{}.fn();
| ~~~~~~~~~~~~~
12 | return 0;
| ~~~~~~~~~
13 | }();
| ~~~
<source>:5:20: note: declared here
5 | consteval void fn() {
| ^
<source>:10:24: error: constexpr variable 'r' must be initialized by a constant _expression_
10 | static constexpr int r = [] {
| ^ ~~~~
11 | Inner{}.fn();
| ~~~~~~~~~~~~~
12 | return 0;
| ~~~~~~~~~
13 | }();
| ~~~
<source>:11:13: note: undefined function 'fn' cannot be used in a constant _expression_
11 | Inner{}.fn();
| ^
<source>:10:28: note: in call to '[] {
Inner{}.fn();
return 0;
}.operator()()'
10 | static constexpr int r = [] {
| ^~~~
11 | Inner{}.fn();
| ~~~~~~~~~~~~~
12 | return 0;
| ~~~~~~~~~
13 | }();
| ~~~
<source>:5:20: note: declared here
5 | consteval void fn() {
| ^
2 errors generated.
```
It seems unfortunate that multi-line lambda body gets printed in the `in call to` note.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs