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

            Bug ID: 121430
           Summary: [CWG 2745] Dependent odr-use in generic lambdas
           Product: gcc
           Version: 15.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: ---

We do not correctly handle the example in [basic.def.odr]/11:

```
void g() {
  constexpr int x = 1;
  auto lambda = [] <typename T, int = ((T)x, 0)> {};    // OK
  lambda.operator()<int, 1>();          // OK, does not consider x at all
  lambda.operator()<int>();             // OK, does not odr-use x
  lambda.operator()<const int&>();      // error: odr-uses x from a context
where x is not odr-usable
}

void h() {
  constexpr int x = 1;
  auto lambda = [] <typename T> { (T)x; };      // OK
  lambda.operator()<int>();             // OK, does not odr-use x
  lambda.operator()<void>();            // OK, does not odr-use x
  lambda.operator()<const int&>();      // error: odr-uses x from a context
where x is not odr-usable
}
```

Reply via email to