https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85348
Bug ID: 85348 Summary: ostringstream with #pragma pack(1) causes stack smashing error Product: gcc Version: 7.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: crillion at tiscali dot it Target Milestone: --- Hi. Using g++ version 7.2.0 on Windows 10 Enterprise N, installed with the Mingw-w64 distribution, version x86_64-7.2.0-posix-seh-rt_v5-rev0, with the following program #pragma pack(1) #include <sstream> int main() { std::ostringstream{}; } that I compile with the script (called from the normal windows console after having added mingw-w64 bin path to the windows PATH variable) g++ -pedantic -std=c++17 -Wall -Wextra -Werror=return-type -fdiagnostics-color -s -Os program.cpp -o program_gpp.exe the program compiles finely, but when I run it I get a crash without error messages. The error occurs both if I don't use the -g option for debug or if I use it. On an older mingw-w64 version i686-510-win32-sjlj-rt_v4, used on a complex cmake project in Debug Mode I get the crash too, with more detail in an explicit console output as " *** stack smashing detected ***: terminated ". In release mode the error does not occur. I understand that with #pragma pack(push,1) and #pragma pack(pop), and also by including <sstream> BEFORE the #pragma pack(1) directive the crash does not occur; But could you please issue a warning if someone uses simply #pragma pack(1) with ostringstream ? Thanks, Marco