g++;警告:将永远不会执行 继承了C++项目。我通过一个生成文件在RHEL5.5中构建GCC4.1.2。该项目是巨大的(数百个文件),一般来说,代码是相当不错的。然而,在编译过程中,我经常会收到一条GCC警告,上面说: /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]’: /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/allocator.h:97: warning: will never be executed /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/allocator.h:97: warning: will never be executed /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/ext/new_allocator.h: In constructor ‘__gnu_cxx::new_allocator<_Tp>::new_allocator() [with _Tp = char]’: /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/ext/new_allocator.h:65: warning: will never be executed /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/allocator.h: In destructor ‘std::allocator<_Alloc>::~allocator() [with _Tp = char]’: /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/allocator.h:105: warning: will never be executed /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/ext/new_allocator.h: In destructor ‘__gnu_cxx::new_allocator<_Tp>::~new_allocator() [with _Tp = char]’: /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/ext/new_allocator.h:72: warning: will never be executed /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/allocator.h: In copy constructor ‘std::allocator<_Alloc>::allocator(const std::allocator<_Alloc>&) [with _Tp = char]’: /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/allocator.h:100: warning: will never be executed /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/allocator.h:99: warning: will never be executed /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/ext/new_allocator.h: In copy constructor ‘__gnu_cxx::new_allocator<_Tp>::new_allocator(const __gnu_cxx::new_allocator<_Tp>&) [with _Tp = char]’: /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/ext/new_allocator.h:67: warning: will never be executed /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/allocator.h: In destructor ‘std::allocator<_Alloc>::~allocator() [with _Tp = char]’: /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/allocator.h:105: warning: will never be executed /usr/lib/gcc/i386 redhat linux/4.1.2/../../../../../../../../../../include/c++/4.1.2/bits/allocator.h:在构造函数“std::allocator::allocator()[with _Tp=char]”中: /usr/lib/gcc/i386 redhat linux/4.1.2/../../../../../../../../include/c++/4.1.2/bits/allocator.h:97:警告:永远不会执行 /usr/lib/gcc/i386 redhat linux/4.1.2/../../../../../../../../include/c++/4.1.2/bits/allocator.h:97:警告:永远不会执行 /usr/lib/gcc/i386 redhat linux/4.1.2/../../../../../../../../../include/c++/4.1.2/ext/new\u allocator.h:在构造函数“\uu gnu\u cxx::new\u allocator::new\u allocator()[带_Tp=char]”中: /usr/lib/gcc/i386 redhat linux/4.1.2/../../../../../../../../include/c++/4.1.2/ext/new_分配器。h:65:警告:永远不会执行 /usr/lib/gcc/i386 redhat linux/4.1.2/../../../../../../../../include/c++/4.1.2/bits/allocator.h:在析构函数“std::allocator::~allocator()[with _Tp=char]”中: /usr/lib/gcc/i386 redhat linux/4.1.2/../../../../../../../../../include/c++/4.1.2/bits/allocator.h:105:警告:永远不会执行 /usr/lib/gcc/i386 redhat linux/4.1.2/../../../../../../../../../include/c++/4.1.2/ext/new\u allocator.h:在析构函数中“\uu gnu\u cxx::new\u allocator::~new\u allocator()[带\u Tp=char]: /usr/lib/gcc/i386 redhat linux/4.1.2/../../../../../../../../include/c++/4.1.2/ext/new_allocator.h:72:警告:永远不会执行 /usr/lib/gcc/i386 redhat linux/4.1.2/../../../../../../../../../../include/c++/4.1.2/bits/allocator.h:在复制构造函数“std::allocator::allocator(const std::allocator&)[with _Tp=char]”中: /usr/lib/gcc/i386 redhat linux/4.1.2/../../../../../../../../../include/c++/4.1.2/bits/allocator.h:100:警告:永远不会执行 /usr/lib/gcc/i386 redhat linux/4.1.2/../../../../../../../../../include/c++/4.1.2/bits/allocator.h:99:警告:永远不会执行 /usr/lib/gcc/i386 redhat linux/4.1.2/../../../../../../../include/c++/4.1.2/ext/new\u allocator.h:在复制构造函数中“\u gnu\u cxx::new\u allocator::new\u allocator(const\u gnu\u cxx::new\u allocator&”)[带\u Tp=char]: /usr/lib/gcc/i386 redhat linux/4.1.2/../../../../../../../../include/c++/4.1.2/ext/new_allocator.h:67:警告:永远不会执行 /usr/lib/gcc/i386 redhat linux/4.1.2/../../../../../../../../include/c++/4.1.2/bits/allocator.h:在析构函数“std::allocator::~allocator()[with _Tp=char]”中: /usr/lib/gcc/i386 redhat linux/4.1.2/../../../../../../../../../include/c++/4.1.2/bits/allocator.h:105:警告:永远不会执行

g++;警告:将永远不会执行 继承了C++项目。我通过一个生成文件在RHEL5.5中构建GCC4.1.2。该项目是巨大的(数百个文件),一般来说,代码是相当不错的。然而,在编译过程中,我经常会收到一条GCC警告,上面说: /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]’: /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/allocator.h:97: warning: will never be executed /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/allocator.h:97: warning: will never be executed /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/ext/new_allocator.h: In constructor ‘__gnu_cxx::new_allocator<_Tp>::new_allocator() [with _Tp = char]’: /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/ext/new_allocator.h:65: warning: will never be executed /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/allocator.h: In destructor ‘std::allocator<_Alloc>::~allocator() [with _Tp = char]’: /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/allocator.h:105: warning: will never be executed /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/ext/new_allocator.h: In destructor ‘__gnu_cxx::new_allocator<_Tp>::~new_allocator() [with _Tp = char]’: /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/ext/new_allocator.h:72: warning: will never be executed /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/allocator.h: In copy constructor ‘std::allocator<_Alloc>::allocator(const std::allocator<_Alloc>&) [with _Tp = char]’: /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/allocator.h:100: warning: will never be executed /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/allocator.h:99: warning: will never be executed /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/ext/new_allocator.h: In copy constructor ‘__gnu_cxx::new_allocator<_Tp>::new_allocator(const __gnu_cxx::new_allocator<_Tp>&) [with _Tp = char]’: /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/ext/new_allocator.h:67: warning: will never be executed /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/allocator.h: In destructor ‘std::allocator<_Alloc>::~allocator() [with _Tp = char]’: /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/allocator.h:105: warning: will never be executed /usr/lib/gcc/i386 redhat linux/4.1.2/../../../../../../../../../../include/c++/4.1.2/bits/allocator.h:在构造函数“std::allocator::allocator()[with _Tp=char]”中: /usr/lib/gcc/i386 redhat linux/4.1.2/../../../../../../../../include/c++/4.1.2/bits/allocator.h:97:警告:永远不会执行 /usr/lib/gcc/i386 redhat linux/4.1.2/../../../../../../../../include/c++/4.1.2/bits/allocator.h:97:警告:永远不会执行 /usr/lib/gcc/i386 redhat linux/4.1.2/../../../../../../../../../include/c++/4.1.2/ext/new\u allocator.h:在构造函数“\uu gnu\u cxx::new\u allocator::new\u allocator()[带_Tp=char]”中: /usr/lib/gcc/i386 redhat linux/4.1.2/../../../../../../../../include/c++/4.1.2/ext/new_分配器。h:65:警告:永远不会执行 /usr/lib/gcc/i386 redhat linux/4.1.2/../../../../../../../../include/c++/4.1.2/bits/allocator.h:在析构函数“std::allocator::~allocator()[with _Tp=char]”中: /usr/lib/gcc/i386 redhat linux/4.1.2/../../../../../../../../../include/c++/4.1.2/bits/allocator.h:105:警告:永远不会执行 /usr/lib/gcc/i386 redhat linux/4.1.2/../../../../../../../../../include/c++/4.1.2/ext/new\u allocator.h:在析构函数中“\uu gnu\u cxx::new\u allocator::~new\u allocator()[带\u Tp=char]: /usr/lib/gcc/i386 redhat linux/4.1.2/../../../../../../../../include/c++/4.1.2/ext/new_allocator.h:72:警告:永远不会执行 /usr/lib/gcc/i386 redhat linux/4.1.2/../../../../../../../../../../include/c++/4.1.2/bits/allocator.h:在复制构造函数“std::allocator::allocator(const std::allocator&)[with _Tp=char]”中: /usr/lib/gcc/i386 redhat linux/4.1.2/../../../../../../../../../include/c++/4.1.2/bits/allocator.h:100:警告:永远不会执行 /usr/lib/gcc/i386 redhat linux/4.1.2/../../../../../../../../../include/c++/4.1.2/bits/allocator.h:99:警告:永远不会执行 /usr/lib/gcc/i386 redhat linux/4.1.2/../../../../../../../include/c++/4.1.2/ext/new\u allocator.h:在复制构造函数中“\u gnu\u cxx::new\u allocator::new\u allocator(const\u gnu\u cxx::new\u allocator&”)[带\u Tp=char]: /usr/lib/gcc/i386 redhat linux/4.1.2/../../../../../../../../include/c++/4.1.2/ext/new_allocator.h:67:警告:永远不会执行 /usr/lib/gcc/i386 redhat linux/4.1.2/../../../../../../../../include/c++/4.1.2/bits/allocator.h:在析构函数“std::allocator::~allocator()[with _Tp=char]”中: /usr/lib/gcc/i386 redhat linux/4.1.2/../../../../../../../../../include/c++/4.1.2/bits/allocator.h:105:警告:永远不会执行,c++,gcc-warning,gcc4,C++,Gcc Warning,Gcc4,它没有给我错误产生的源文件或行号。我要冒险说GCC的标题很好,所以这里发生了什么?我以前从未遇到过这种特殊的警告。根据位于的gcc bug 46158,-Wunreachable code一直被破坏,并从gcc-4.5起被删除。很可能你的问题实际上不是问题。(我个人认为,除非有特殊的理由使用 4.1.2 ,否则它将是一个较新的GCC/G+ +,它已经将近6年了。 < P>这个bug报告在底部 -Wunreachable代码已损坏,已从GCC 4.5中删除。不要使用它 因此,忽略警告听起来并不是一

它没有给我错误产生的源文件或行号。我要冒险说GCC的标题很好,所以这里发生了什么?我以前从未遇到过这种特殊的警告。

根据位于的gcc bug 46158,
-Wunreachable code
一直被破坏,并从
gcc-4.5
起被删除。很可能你的问题实际上不是问题。(我个人认为,除非有特殊的理由使用<代码> 4.1.2 ,否则它将是一个较新的GCC/G+ +,它已经将近6年了。

< P>这个bug报告在底部

-Wunreachable代码已损坏,已从GCC 4.5中删除。不要使用它


因此,忽略警告听起来并不是一个完全糟糕的主意。

非主题:谷歌搜索“警告:永远不会执行”\uu gnu\u cxx::new\u allocator”返回此页面作为第二个结果。头asplode@Bribles第一个结果返回一个“-Wunreachable代码已被破坏并已从GCC 4.5中删除”。建议从CXXFLAGS中删除此警告选项。@harpun您的google fu很强大!实际上,我并没有把二和二放在一起,并意识到错误是由CXXFLAG选项造成的。升级gcc在列表中。我认为使用已知的工作配置设置项目环境是一个很好的第一步。不过,我很想看看我在gcc升级中遇到了哪些“有趣”的问题。