Cin not working with empty when_GLIBCXX_DEBUG string on Windows?

Very strange behavior happened to me. I use the latest Cygwin32, Cygwin64 and MinGW32 with GCC 4.9.2, 4.9.2 and 4.8.1 respectively on Windows 7 64-bit. I am also testing on 32-bit Linux using GCC 4.8.2.

So, on all systems, this works.

#include <bits/stdc++.h> using namespace std; string s,t; int main(){ cin>>s>>t; cout<<s; } 

and it works

 #define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; string s="a",t="b"; int main(){ cin>>s>>t; cout<<s; } 

but the following crashes on Windows after entering the first line of the 3 configurations mentioned above, but it works correctly on Linux:

 #define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; string s,t; int main(){ cin>>s>>t; cout<<s; } 

Clearly, the only difference is that the line is empty before entering, and _GLIBCXX_DEBUG is turned on.

Firstly, is this a reproducible problem? that is, it happens on every PC with the same configuration, or only on my PC? Secondly, what is the problem? What should I do? I explicitly need _GLIBCXX_DEBUG to debug other STL structures in the code.

+6
source share

Source: https://habr.com/ru/post/982965/


All Articles