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

--- Comment #10 from Johel Ernesto Guerrero Peña <johelegp at gmail dot com> ---
Another workaround, extended from Bug 92320's example. See
https://godbolt.org/z/69onWf.
You can wrap the closure object in a template function which itself invokes the
closure object and converts to a function pointer that GCC accepts.
```C++
template<auto V>
void templ() {}

void dummy(){}

template<auto F>
void fn(){F();}

void foo() {
    constexpr int a = 7 + 3;
    templ<a>();

    templ<dummy>();

    typedef void(FPtr)();
    constexpr FPtr * b = &dummy;
    templ<b>();

    constexpr auto l = []{};
    constexpr void (*d)()=fn<l>;
    templ<d>();

    constexpr FPtr * c = [](){};
    templ<c>();
}

```

Reply via email to