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

            Bug ID: 110584
           Summary: Constant is not visible in nested lambda
           Product: gcc
           Version: 13.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fchelnokov at gmail dot com
  Target Milestone: ---

This program (created by my colleague Artur)

void foo(float);
int main() {
    constexpr float x = 0;
    (void)[&] () {
        foo(x);
        (void)[] () {
            foo(x);
        };
    };
}

is accepted in Clang and MSVC, but GCC complains:

error: 'x' is not captured
note: the lambda has no capture-default
'const float& x' declared here
    5 |         foo(x);

Online demo: https://gcc.godbolt.org/z/dY8bPhMYc

Reply via email to