如何调试g++的分段错误?
我尝试在 aix 6.1 上使用 g++4.4.6 编译代码。我没有安装gdb。 编译后,它显示分段错误错误:-
../test/Corner.h: In member function 'void VirtualFlow<T>::vector_flow(typename T::Data**, typename T::Data**) [with T = NProcess<or_func<NetAndVal<ZVal2>, with_derivatives>, ConvexNoOverlapSize<16, 16, Multiply<65536l, AllPass<CornerT<NetAndVal<ZVal2> >, NoFlow<CornerT<NetAndVal<ZVal2> > > > > > >]':
../test/Corner.h:369: internal compiler error: Segmentation fault
我尝试使用 -g 选项创建 .o 文件并查找问题。
opt/freeware/bin/g++ -g ConnectFlow2.C -o ConnectFlow2.o
但我无法调试。
请分享如何调试分段错误的良好实践。
谢谢。
I tried to compile the code using g++4.4.6 on aix 6.1. I dont have gdb installed.
After compilation, It is showing Segmentation Fault error:-
../test/Corner.h: In member function 'void VirtualFlow<T>::vector_flow(typename T::Data**, typename T::Data**) [with T = NProcess<or_func<NetAndVal<ZVal2>, with_derivatives>, ConvexNoOverlapSize<16, 16, Multiply<65536l, AllPass<CornerT<NetAndVal<ZVal2> >, NoFlow<CornerT<NetAndVal<ZVal2> > > > > > >]':
../test/Corner.h:369: internal compiler error: Segmentation fault
I tried to use -g option with to create .o file and looked for the problem.
opt/freeware/bin/g++ -g ConnectFlow2.C -o ConnectFlow2.o
but I was not able to debug.
Please share good practices of how to debug the segmentation fault.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
简化代码以保留 ICE 仍然发生的最低限度,并向 GCC 项目提交错误报告。他们解决问题的机会比你高得多。
Simplify the code to leave the bare minimum for which the ICE still occurs and submit a bug report to GCC project. They have much higher chances of resolving it than you do.
我建议升级你的 GCC 编译器(因为你的旧 4.4 编译器崩溃了)。尝试获取 GCC 4.6 源代码,然后构建它。
不要忘记担心依赖关系,并仔细阅读并遵循安装说明(特别是,不要在源目录中构建!)。
如果您确实想自己调试编译器,请从源代码重建它并使用
-g
重新编译它I suggest upgrading your GCC compiler (since your old 4.4 compiler crashes). Try to get the GCC 4.6 source code then build it.
Don't forget to worry about dependencies, and to carefully read and follow the installation instructions (in particular, don't build in the source directory!).
If you really want to debug your compiler by yourself, rebuild it from source and recompile it with
-g
这只是一个猜测,但值得尝试使用
-ftemplate-depth-103
来增加模板深度。我不知道默认值是什么,以及你的模板结构有多深。It's just a guess, but it would worth trying to increase template depth with
-ftemplate-depth-103
. I don't know what is the default value, and how deep is your template-structure.