llvm-gcc std:: 分配器错误?
代码:
#include <vector>
#include <stack>
using namespace std;
class blub {};
class intvec : public std::vector<int, std::allocator<int> >, public blub {};
int main()
{
std::stack<int, intvec> s;
}
使用 g++ (4.4.3) 和 llvm-g++ (4.2.1) 进行编译,但后者的输出出现 seg 错误:
$ g++ main.cc && ./a.out
$ llvm-g++ main.cc && ./a.out
Segmentation fault
这似乎是释放未分配的内容的问题。这是 llvm-gcc 中的错误吗?
更新:根据 llvm 邮件列表上的讨论,看起来这是 llvm-gcc 或其 STL 实现中的一个错误,该错误已在较新版本中修复。然而,我并没有费心从他们的存储库中安装和构建 llvm-gcc 来找出答案。
The code:
#include <vector>
#include <stack>
using namespace std;
class blub {};
class intvec : public std::vector<int, std::allocator<int> >, public blub {};
int main()
{
std::stack<int, intvec> s;
}
compiles with both g++ (4.4.3) and llvm-g++ (4.2.1), but the output of the latter seg faults:
$ g++ main.cc && ./a.out
$ llvm-g++ main.cc && ./a.out
Segmentation fault
It appears to be an issue of freeing something that wasn't allocated. Is this a bug in llvm-gcc?
Update: Based on the discuss on the llvm mailing list, it looks like this is a bug, either in llvm-gcc or its implementation of the STL that has been fixed in newer versions. I haven't bother to install and build llvm-gcc from their repository to find out, however.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
好的。所以我在 Ubuntu 10.10 x64 上运行了这个,我看到了分段错误。这是一些细节。总的来说,我的总结似乎是这是编译器中的一个错误。 (请注意,我不是最初的提问者,我只是能够重现他的结果)。
我还将此转发到 llvm 邮件列表,网址为 http://lists.cs.uiuc.edu/pipermail/llvmdev/2010-11 月/036231.html< /a>
我们还获得了无效指针的释放。从回溯来看这是有道理的。
我稍微减少了测试用例。我实际上倾向于认为这是 STL 实现错误,而不是编译器错误。
Okay. So I ran this on Ubuntu 10.10 x64 and I see the segmentation fault. Here's some details. In general, my summary seems to be that this is a bug in the compiler. (Note that I'm not the original question asker, I was merely able to reproduce his results).
I've also forwarded this to the llvm mailing list at http://lists.cs.uiuc.edu/pipermail/llvmdev/2010-November/036231.html
We also get a free of an invalid pointer. Which makes sense from the traceback.
I reduced the test case a bit. I'm actually leaning towards this being a STL implementation error, rather than a compiler error.
要了解实际发生的情况,请尝试使用
-g
标志进行编译以启用调试信息,然后运行 valgrind ./a.out
来获取堆栈跟踪发生段错误的地方。To figure out what's actually happening, try to compile with the
-g
flag to enable debug information to be emitted, then runvalgrind ./a.out
to get a stack trace where the segfault occurs.对我来说没有段错误,你使用什么平台?
does not segfault for me, what platform are you using?