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

            Bug ID: 95451
           Summary: [8/9/10 regression] ICE for lambda capturing this and
                    calling operator()
           Product: gcc
           Version: 10.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: max.kan...@nu-cost.com
  Target Milestone: ---

The following legal code will lead to an Internal Compiler Error, see
https://godbolt.org/z/PoyMEL

================================
struct A {
    template<typename>
    void function_with_lambda() {
        [this](auto) {
            /*this->*/operator()();
        };
    }

    void operator()() {}
};

int main() {
    A{}.function_with_lambda<void>();
}
================================

A simple workaround is explicitely adding "this->" before the function call.
This is familiar to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86594, where
the same workaround prevents the ICE.

Reply via email to