开发者

typeinfo cause a segmentation fault

I hava a segmentation fault. debug with gdb, the first开发者_JAVA百科 frame in the stack is

in the typeinfo for MyClass()

does someone know something about the typeinfo ?


Had the same problem; posting the solution, as it might help someone else:

Making a clean rebuild of the project solved the problem - some of the object files used different versions of a header file and that caused an inconsistency. The actual bug is in my building script, as dependencies are not correctly expressed.


I suspect that the typeinfo being the top of the frame is totally a red herring in this case. You need to go up the callstack until you find your own code and look in more detail at that point. Almost certainly you're trying to get typeinfo from a null pointer but it's somewhat possible it's just a garbage pointer value (which would be less obvious).


RTTI only applies to classes with at least a virtual method, so make sure you have one.

Also, remember that you can use RTTI directly (dynamic_cast, typeinfo, typeid) ou indirectly (catch is or can be implemented in terms of dynamic_cast).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜