我继承了一个C++项目。我正在建设RHEL https://en.wikipedia.org/wiki/Red_Hat_Enterprise_Linux5.5 通过 makefile 使用 GCC 4.1.2。该项目非常庞大(数百个文件),并且总的来说代码非常好。然而,在编译过程中,我经常会收到一条 GCC 警告,上面写着 (prefix "/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2
"):
/bits/allocator.h: In constructor ‘std::allocator<_Alloc>::allocator() [with _Tp = char]’:
/bits/allocator.h:97: warning: will never be executed
/bits/allocator.h:97: warning: will never be executed
/ext/new_allocator.h: In constructor ‘__gnu_cxx::new_allocator<_Tp>::new_allocator() [with _Tp = char]’:
/ext/new_allocator.h:65: warning: will never be executed
/bits/allocator.h: In destructor ‘std::allocator<_Alloc>::~allocator() [with _Tp = char]’:
/bits/allocator.h:105: warning: will never be executed
/ext/new_allocator.h: In destructor ‘__gnu_cxx::new_allocator<_Tp>::~new_allocator() [with _Tp = char]’:
/ext/new_allocator.h:72: warning: will never be executed
/bits/allocator.h: In copy constructor ‘std::allocator<_Alloc>::allocator(const std::allocator<_Alloc>&) [with _Tp = char]’:
/bits/allocator.h:100: warning: will never be executed
/bits/allocator.h:99: warning: will never be executed
/ext/new_allocator.h: In copy constructor ‘__gnu_cxx::new_allocator<_Tp>::new_allocator(const __gnu_cxx::new_allocator<_Tp>&) [with _Tp = char]’:
/ext/new_allocator.h:67: warning: will never be executed
/bits/allocator.h: In destructor ‘std::allocator<_Alloc>::~allocator() [with _Tp = char]’:
/bits/allocator.h:105: warning: will never be executed
它没有给我错误来源的源文件或行号。我要大胆地说 GCC 的标头很好,那么这里发生了什么?我以前从未遇到过这个特殊的警告。
根据海湾合作委员会错误 46158 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46158, -Wunreachable-code https://gcc.gnu.org/onlinedocs/gcc-4.4.7/gcc/Warning-Options.html#index-Wunreachable_002dcode-437自 GCC 4.5 以来一直被破坏并被删除。
您的问题很可能实际上不是问题。 (就我个人而言,我仍然会考虑更新的gcc
/g++
除非有特殊原因使用 4.1.2 - 它已经有将近 6 年历史了。)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)