2016-09-23 18 views
10

Korzystanie GCC 6.1, następujący program:Co robi GCC dla mojej zmiennej statycznej w lambda?

#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; 
    }); 
} 

Drukuje:

foo outside: foo 
foo inside: 

Live On Coliru

Co się dzieje?

+0

mam żadnych problemów z gcc 6.2.1 i kodzie. – gj13

+0

Zespół deweloperów gcc, cały twój bugware należy do nas –

+0

gcc 6.1.1 również nie ma problemu – ks1322

Odpowiedz