https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95103
Bug ID: 95103 Summary: Unexpected -Wclobbered in bits/vector.tcc with -O2 Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: sbergman at redhat dot com Target Milestone: --- I have seen this with at least some GCC 7, and still see it with GCC 10 and with recent trunk: > $ cat test.cc > #include <csetjmp> > #include <vector> > struct S { > S(int); > ~S(); > }; > void f1(); > bool f2(char const (& s)[3]) { > for (int i = 0; i != 2; ++i) { > if (s[i] != 'x') { > return false; > } > } > return true; > } > void f3() { > std::vector<S> v; > for (int i = 0; i != 2; ++i) { > if (!f2("xx")) f1(); > v.push_back(0); > } > std::jmp_buf b; > setjmp(b); > } > $ g++ -Wclobbered -O2 -c test.cc > In file included from /usr/include/c++/10/vector:72, > from test.cc:2: > /usr/include/c++/10/bits/vector.tcc: In function ‘void f3()’: > /usr/include/c++/10/bits/vector.tcc:441:15: warning: variable ‘__new_finish’ > might be clobbered by ‘longjmp’ or ‘vfork’ [-Wclobbered] > 441 | pointer __new_finish(__new_start); > | ^~~~~~~~~~~~