pragma pack(push) without corresponding pop leads to stack smashing
问题 I used #pragma pack(push, 2) at the beginning of a struct in a header file but forgot the corresponding #pragma pack(pop) . After including this header file, I included fstream. On creating an ofstream object, I am seeing stack smashing. Details of the exact scenario and code are as follows. I was following a C++ course and had written a code for the project. My program was crashing due to stack smashing. I tried to look for any obvious overflow errors but couldn't find any. I changed almost