https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96188
Bug ID: 96188 Summary: -Wstringop-overflow false positive Product: gcc Version: 10.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: derek.mauro at gmail dot com Target Milestone: --- This is strange issue that started appearing in gcc 10.1. It also seems to require -O3 and -std=gnu++11 (gnu++14 etc appear unaffected). Godbolt demo: https://godbolt.org/z/W8MWbz Test case copy/pasted below. Use -Werror -Wstringop-overflow -std=gnu++11 -O3 #include <string> #include <vector> bool b; void F() { static bool b2 = b; for (const int fx : {0}) { struct Expectation { std::string out; }; std::vector<Expectation> expect = { {std::string()}, {std::string()}, {std::string()}, }; if (b2) { expect.push_back({std::string()}); } } }