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

            Bug ID: 110211
           Summary: Local lambda treated as non-local
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: c++-lambda, rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: johelegp at gmail dot com
                CC: johelegp at gmail dot com
  Target Milestone: ---

See <https://compiler-explorer.com/z/W9PzEcc1v>.

```C++
template<class F, class T> concept invocable = requires(F f, T x) { f(x); };
static_assert(!invocable<
              decltype([]<class T>(T) -> decltype([&]<class U>(U x)
                                                    requires requires { x.a();
}
                                                  {}(T())) {}),
                       int>);
```

```output
<source>:3:52: error: non-local lambda expression cannot have a capture-default
    3 |               decltype([]<class T>(T) -> decltype([&]<class U>(U x)
      |                                                    ^
Compiler returned: 1
```

According to <https://eel.is/c++draft/expr.prim.lambda#capture-3>, this should
work.
If the `static_assert` is in a function, it still fails:
<https://compiler-explorer.com/z/b7rdqfxed>.
It fails on GCC10: <https://compiler-explorer.com/z/znsYvKdz1>.

Reply via email to