由于高输入,应用程序崩溃
我的应用程序因信号 11 - 分段错误而终止。
核心转储已生成,内容如下:
#0 Players::shareExperience (this=0x7fd3f8187600,
experience=401912970206.76483154296875, m=<value optimized out>,
multiplied=<value optimized out>) at players.cpp:130
130 (*it)->gainSharedExperience(tmpExperience, m , multiplied);
当玩家杀死怪物并获得大量经验时,就会发生这种情况。
在我看来,它不应该崩溃,因为 130
行的体验是 long double
,所以它应该处理这个问题。
有什么办法可以处理这么大的数字吗?这可能就是玩家杀死怪物时获得的体验:experience=401912970206.76483154296875
long double
还不够吗?
My application is terminating with signal 11 - segmentation fault.
Core dump has been generated, and it say the following:
#0 Players::shareExperience (this=0x7fd3f8187600,
experience=401912970206.76483154296875, m=<value optimized out>,
multiplied=<value optimized out>) at players.cpp:130
130 (*it)->gainSharedExperience(tmpExperience, m , multiplied);
This happends, when player is killing a monster, and get high amount of experience.
In my opinion, it shouldn't crash, because the expierience on 130
line is a long double
, so it should handle that.
Is there any way, to handle that big amount of numbers? This is probably the expierience that player get when monster it killed: experience=401912970206.76483154296875
isnt long double
enough for that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该错误不是来自大的 long double 值,很可能是由于取消引用
it
中的无效迭代器(或具有无效指针值的迭代器)。That fault is not from the large long double value, it is most likely from dereferencing an invalid iterator in
it
(or an iterator with an invalid pointer value).