核心文件完全是废话,或者这段代码真的抛出了 SIGFPE 吗?

发布于 2024-10-03 04:40:26 字数 632 浏览 4 评论 0原文

抛出了 SIGFPE。

我的核心文件声称从第 176 行的gcc-4.3.4/include/c++/4.3.4/bits/stl_iterator_base_funcs.h

这在这里:

  template<typename _InputIterator, typename _Distance>
    inline void
    advance(_InputIterator& __i, _Distance __n)
    {
          // concept requirements -- taken care of in __advance
176---->  typename iterator_traits<_InputIterator>::difference_type __d = __n;
          std::__advance(__i, __d, std::__iterator_category(__i));
    }

这是在我拥有的另一个函数内,该函数确实在调用 advance around通过不执行任何浮点运算的代码。代码是经过优化编译的(但有调试符号),所以事情可能会很混乱。

我的核心文件只是告诉我完全是胡说八道还是有办法让这有意义?

My core file claims that a SIGFPE was thrown from

gcc-4.3.4/include/c++/4.3.4/bits/stl_iterator_base_funcs.h

on line 176. This is here:

  template<typename _InputIterator, typename _Distance>
    inline void
    advance(_InputIterator& __i, _Distance __n)
    {
          // concept requirements -- taken care of in __advance
176---->  typename iterator_traits<_InputIterator>::difference_type __d = __n;
          std::__advance(__i, __d, std::__iterator_category(__i));
    }

this is inside another function I have that is indeed calling advance surrounding by code that isn't doing any floating point arithmetic. The code is compiled with optimizations (but has debugging symbols), so things may be a big obfuscated.

Is my core file just telling me complete nonsense or is there a way this could make sense?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

等你爱我 2024-10-10 04:40:26

在回答我自己的问题时,优化器采用了如下所示的代码

int which = RANDOM % somecontainer.size();
std::advance(it, which);

并将它们组合起来。这就是为什么信号似乎是从 std::advance 内部发出的。根据 Oli 的评论,当您取相对于 0 的模数时,即使它不是浮点运算,也会发生 SIGFPE。还有一个不同的错误,它允许某些容器在极端情况下为空。

In answer to my own question, what happened is that optimizer took code that looked like this:

int which = RANDOM % somecontainer.size();
std::advance(it, which);

and combined them. This is why it appears the signal was raised from inside std::advance. Following Oli's comment, SIGFPE can occur when you take the modulus with respect to 0, even though it isn't a floating point operation. There was a different bug which allowed somecontainer to be empty in a corner case.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文