Using GCC 6.1, the following program:
#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;
});
}
Prints:
foo outside: foo
foo inside:
Live On Coliru
What's going on?
This bug is already filed as Bug 69078 and yet unconfirmed.
See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69078
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With