> The following C++ program crashes when compiled with GCC (both 5.4 and 6.3) under Cygwin, when compiled with both an optimization level higher than -O0 (i.e. -O1, -O2 or -O3) and the C++ standard set to -std=c++nn (for any supported nn, i.e. 98, 03, 11, 14 or 17): > ``` > #include > #include > int main() > { > std::string s; > std::getline(std::cin, s); > std::cout << "You entered \"" << s << "\".\n"; > return 0; > } > ``` > On the other hand, when compiled with -std=gnu++nn or -O0, the program executes normally. For details, run the attached Bash script test_getline.sh, which produces the output contained in the attached file test_getline_Cygwin.txt . No similar problem shows with GCC under Linux. > It looks similar to the problem reported in https://cygwin.com/ml/cygwin/2017-07/msg00088.html which appears to be circumvented by passing -std=gnu++11 instead of -std=c++11. I've tried it with both cygwin-devel-2.8.0-1 and cygwin-devel-2.8.1-1. With cygwin-devel-2.8.1-1, reproduced. With cygwin-devel-2.8.0-1, there is no problem. I've attached the script that I used and the results.