Hi, ive started learning c++ about 3 week ago so be lenient with the code style.
Im writing a solver for sokoban.
I've written a method to write a txt file (with times and other stats). The strange thing that is happening is that if I uncoment this line of code "ofstream aFile;" it changes the behavior of the rest of the program without the method in witch its declared ever being called (I put a flashy cout in the beginig of the method to make sure im not calling it by mistake)
The method can be emty with only this declaration (ofstream aFile;) and even with the method never being called, even then it ruins the behavior of the rest of the code.
This problem happens if and only if I compile with the O3 option and the line is not commented.(regardless if the method is called) UPDATE: It does happens without any O option turned on the change in O's was just forcing a full ercompile
Some extra comments
Im using g++ to compile in ubuntu and valgrind finds nothing wrong with my code
I have this field in the class in which its declared (Node)
Board* boardP;
Board has (amongst others) this fields
std::list<int> boxesRow;
std::list<int> boxesCol;
When I compile with O3 and that line isn't commented (ofstream aFile;) the lists above start to loose elements/fill the elements with junk (even if the method in which the ofstream is declared is never called). If i compile without O3 or without that line it does the correct actions.
The code itself is to big to be posted but the main culprit is: