https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68209
Bug ID: 68209 Summary: C++11 code compiled without -std=c++11 but doesn't work as expected Product: gcc Version: 5.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: mirzayanovmr at gmail dot com Target Milestone: --- Tried on g++.EXE (tdm-1) 5.1.0 and g++ (GCC) 5.1.1 20150618 (Red Hat 5.1.1-4). This code compiled successfully with command line 'g++ a.cpp' #include <vector> #include <iostream> using namespace std; int main() { vector<int> a; for (int aa: a) cout << aa << endl; } It prints warrning 'warning: range-based ‘for’ loops only available with -std=c++11 or -std=gnu++11' but it is not a error. I expected behaviour like on 4.9.2: it gives error 'error: range-based 'for' loops are not allowed in C++98 mode' As a result code compiled but doesn't work correctly. It prints lines containing "0" infinitely. I expect that such code shouldn't be compiled or at least (if compiled) work as expected.