fork download
#include 
#include 
using namespace std;

const function* pointer;

void a(const function & f)
{
    pointer = &f;
}

void b()
{
    (*pointer)();
}

int main()
{
    int value = 1;
    std::cout << value << std::endl;

    // 1: this works    
    function f = [&] () { std::cout << value << std::endl; };
    a(f);

    // 2: this doesn't
    a([&] () { std::cout << value << std::endl; });
    //c();
    char data[1024];
    for (int i = 0; i < 1024; i++)
        data[i] = i % 4; 

    b();

    return 0;
}
Runtime error #stdin #stdout 0s 3016KB
stdin
Standard input is empty
stdout
1