https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124488
Bug ID: 124488
Summary: wrong "not captured" with expansion statements
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: mpolacek at gcc dot gnu.org
Target Milestone: ---
```
//#define HACK // uncomment this line to fix
int main() {
template for (constexpr decltype(^^::) dm : {^^int}) {
#ifdef HACK
constexpr auto dmcopy = dm;
#endif
(void)[](){
#ifdef HACK
(void) dmcopy;
#else
(void) dm;
#endif
};
}
}
```
$ ./cc1plus -quiet -std=c++26 -freflection e1.C
e1.C: In lambda function:
e1.C:12:14: error: ‘dm’ is not captured [-Wtemplate-body]
12 | (void) dm;
| ^~
e1.C:8:12: note: the lambda has no capture-default
8 | (void)[](){
| ^
e1.C:4:42: note: ‘constexprstd::meta::info dm’ declared here
4 | template for (constexpr decltype(^^::) dm : {^^int}) {
| ^~