public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/106330] New: Unknown type leads to error messages about missing lambda capture
@ 2022-07-16 21:33 drahflow at gmx dot de
0 siblings, 0 replies; only message in thread
From: drahflow at gmx dot de @ 2022-07-16 21:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106330
Bug ID: 106330
Summary: Unknown type leads to error messages about missing
lambda capture
Product: gcc
Version: 11.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: drahflow at gmx dot de
Target Milestone: ---
Running g++ on
void unhelpful(int i) {
Unknown u;
u.distract();
for(auto &i: u) {
[i]() {
unhelpful(i);
};
}
}
outputs
test.c++: In function 'void unhelpful(int)':
test.c++:2:5: error: 'Unknown' was not declared in this scope
2 | Unknown u;
| ^~~~~~~
test.c++:3:5: error: 'u' was not declared in this scope
3 | u.distract();
| ^
test.c++: In lambda function:
test.c++:7:23: error: 'i' is not captured
7 | unhelpful(i);
| ^
test.c++:6:11: note: the lambda has no capture-default
6 | [i]() {
| ^
test.c++:5:15: note: '<typeprefixerror>i' declared here
5 | for(auto &i: u) {
| ^
Compiler returned: 1
The error message for line 7 together with the two notes are quite unhelpful.
(Of course the example where I encountered the problem had a lot more code
between u.distract() and for(auto &i: u) ... )
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-07-16 21:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-16 21:33 [Bug c++/106330] New: Unknown type leads to error messages about missing lambda capture drahflow at gmx dot de
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).