Compiling the following with "-Wunreachable-code -D_GLIBCXX_DEBUG" -------------------------- #include <vector>
int main() { std::vector<int>::iterator a; } -------------------------- produces the warning : -------------------------- /usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/debug/safe_iterator.h: In constructor __gnu_debug::_Safe_iterator<_Iterator, _Sequence>::_Safe_iterator() [with _Iterator = __gnu_cxx::__normal_iterator<int*, __gnu_norm::vector<int, std::allocator<int> > >, _Sequence = __gnu_debug_def::vector<int, std::allocator<int> >]: /usr/lib/gcc/i386-redhat-linux/4.1.1/../../../../include/c++/4.1.1/debug/safe_iterator.h:103: warning: will never be executed -------------------------- I tried g++ 4.1, 4.2 and 4.3. They all produce this annoying warning. Looking at the code in safe_iterator.h shows nothing obviously wrong. This might even suggest a bug in -Wunreachable-code, although I categorized it for now in libstdc++, as I have not been able to isolate a small piece of code that reproduces the problem. Some other compilers tend to have the equivalent of -Wunreachable-code by default. It would be nice if it worked well, and if it was enabled by -Wall or -Wextra. -- Summary: Strange -Wunreachable-code warning with _GLIBCXX_DEBUG Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: sylvain dot pion at sophia dot inria dot fr GCC host triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31246