I am trying to run this code with optimization key -O3 (-O1 and O2 also do not work)
main.cpp:
#include "my_file.hpp"
int main(int argc, char* argv[]){
test_another();
return 0;
}
my_file.hpp:
#include <string>
#include <fstream>
void test_another(){
std::ifstream bar;
bar.open("C:\\Users\\ische\\source\\repos\\OpenMpCpp\\test.in");
}
What I get: "Exception has occurred. Segmentation fault" in istream file when basic_istream() is called.
If function test_another() is moved to the main.cpp file - all works fine even with -O3 key. If program is compiled without any optimization key (O1, O2, O3) then it is a successful compilation.
I use Windows10, compiler is g++ from MinGW package: g++.exe (MinGW.org GCC-6.3.0-1) 6.3.0
Anyone has any ideas why is this happening?