GCC对lambda中的静态变量做了什么?

Dan*_*iel 10 c++ lambda static gcc c++11

使用GCC 6.1,以下程序:

#include <string>
#include <vector>
#include <iterator>
#include <algorithm>
#include <iostream>

int main()
{
    static const std::string foo {"foo"};
    std::vector<std::string> bars {{""}};
    std::cout << "foo outside: " << foo << std::endl;
    std::for_each(std::cbegin(bars), std::cend(bars), [] (const auto& bar) {
        std::cout << "foo inside: " << foo << std::endl;
    });
}
Run Code Online (Sandbox Code Playgroud)

打印:

foo outside: foo
foo inside: 
Run Code Online (Sandbox Code Playgroud)

Live On Coliru

这是怎么回事?

Tre*_*vir 1

该错误已被归档为错误 69078,但尚未得到确认。

请参阅:https://gcc.gnu.org/bugzilla/show_bug.cgi? id=69078