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

--- Comment #6 from Stas Sergeev <stsp at users dot sourceforge.net> ---
(In reply to Andrew Pinski from comment #5)
> Nope, lamdba's are not a nested class.

But according to this:
https://timsong-cpp.github.io/cppwp/n3337/expr.prim.lambda#3
The type of the lambda-expression (which is also the type of the closure
object) is a unique, unnamed non-union class type — called the closure type —
whose properties are described below. This class type is not an aggregate
([dcl.init.aggr]). The closure type is declared in the smallest block scope,
class scope, or namespace scope that contains the corresponding
lambda-expression.

So am I right that defining lambda
in class A, means defining it in a
class's scope? In which case note4
should apply? What am I missing?

Additionally I've got this to compile:

struct A {
    struct dummy {
        static constexpr int foo(int off = offsetof(A, a)) { return off; }
        static constexpr int operator()() { return foo(); }
    };
    static constexpr int (*off_p)() = &dummy::operator();

    int x;
    char a;
};

Seems like note4 applies in that case.
But it should be very similar to the
"closure type" described above...

Reply via email to