https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118668

            Bug ID: 118668
           Summary: lambda explict reference to anonymous union is allowed
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid, c++-lambda
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Take:
```
void test1() {
  union  { int a; int b; };
  [&a] { (void)a;}(); // #1
  [&b] { (void)b; }(); // #2
}


void test2() {
  union  { int a; int b; };
  [&] {(void)a;}(); // #1
  [&] {(void)b; }(); // #2
}
```

GCC rejects both cases in test2 but accepts both cases in test1. BUT explicit
vs implicit reference of anonymous union fields should not make a difference
here.

Reply via email to