https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70735
Bug ID: 70735
Summary: problem combining std::function, generic lambdas and
static variables
Product: gcc
Version: 5.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: paolo.monteverde at gmail dot com
Target Milestone: ---
The code
#include <iostream>
#include <functional>
int main()
{
static int a;
std::function<void(int)> f = [](auto) { std::cout << a << '\n'; };
a = 1;
f(0);
}
prints "0" instead of "1". Compiled with "g++ -std=c++14"; verified on Arch and
Ubuntu with GCC 5.3.0. Though, using coliru, it works well:
http://coliru.stacked-crooked.com/a/abff4a693ebcaf86