[Bug c++/105878] New: Error message for const usage inside a capture should be improved
pinskia at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Jun 8 01:01:12 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105878
Bug ID: 105878
Summary: Error message for const usage inside a capture should
be improved
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Take:
```
void f(int a)
{
[& const a](){};
}
```
The current error message is:
```
<source>: In function 'void f(int)':
<source>:3:5: error: expected ',' before 'const'
3 | [& const a](){};
| ^~~~~~
| ,
<source>:3:6: error: expected identifier before 'const'
3 | [& const a](){};
| ^~~~~
```
clang gives:
```
<source>:3:6: error: expected variable name or 'this' in lambda capture list
[& const a](){};
^
```
Which is slightly better.
but I think we could do better and say qualifers should not be in the capture
list.
More information about the Gcc-bugs
mailing list