我是尽我所能缩小下来,这似乎是一个错误......这是libC++ std :: search_n的崩溃吗?
#include <algorithm>
#include <vector>
int main(int argc, char *argv[])
{
// Crashes
std::vector<uint8_t> bs{1, 0, 0};
std::search_n(bs.begin(), bs.end(), 3, 1);
// Does not crash
std::vector<uint8_t> bs{1, 0};
std::search_n(bs.begin(), bs.end(), 2, 1);
return 0;
}
我得到
Segmentation fault: 11
我希望我没有使用std :: search_n错误:)
使用LLDB目前看起来不可能使用STL实现。
版本信息:
$clang --version
Apple LLVM version 4.2 (clang-425.0.24) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin12.3.0
Thread model: posix
证据;)
13:06:47 ~/bug$ cat bug.cc
#include <algorithm>
#include <vector>
int main(int argc, char *argv[])
{
std::vector<uint8_t> bs{1, 0, 0};
std::search_n(bs.begin(), bs.end(), 3, 1);
// std::vector<uint8_t> bs{1, 0};
// std::search_n(bs.begin(), bs.end(), 2, 1);
return 0;
}
13:06:52 ~/bug$ clang++ -std=c++11 -stdlib=libc++ bug.cc -o bug
13:07:36 ~/bug$ ./bug
Segmentation fault: 11
13:07:42 ~/bug$
不会崩溃与叮当3.2:[http://liveworkspace.org/code/tRPXH$2](http://liveworkspace.org/code/tRPXH$2) – interjay 2013-04-04 11:53:05
工作正常与GNU libstdC++,并没有什么可疑的是你使用了'find_n'(除非你没有使用返回值,而使用这些输入的搜索将始终失败)。 – 2013-04-04 11:54:23
@interjay但是使用libC++或libstdC++的liveworkspace? – 2013-04-04 11:56:29