https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77340
Bug ID: 77340 Summary: Invalid (Stack Smashing) Code Generated In Simple Cases With Debug-Mode Vectors Product: gcc Version: 6.1.1 Status: UNCONFIRMED Keywords: wrong-code Severity: major Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ian at geometrian dot com Target Milestone: --- Simple test case: //func.hpp #define _GLIBCXX_DEBUG #include <vector> std::vector<int> func(); //func.cpp #include "func.hpp" std::vector<int> func() { return std::vector<int>(); } //main.cpp #include <cstdio> //Necessary to cause error #include "func.hpp" int main(int /*argc*/, char* /*argv*/[]) { func(); return 0; } Compile with "g++ *.cpp" and run ("./a.out"). Produces: *** stack smashing detected ***: ./a.out terminated Aborted (core dumped)