【发布时间】:2013-03-25 18:37:26
【问题描述】:
看看这段代码:
#include <iostream>
#include <string>
void foo(int(*f)()) {
std::cout << f() << std::endl;
}
void foo(std::string(*f)()) {
std::string s = f();
std::cout << s << std::endl;
}
int main() {
auto bar = [] () -> std::string {
return std::string("bla");
};
foo(bar);
return 0;
}
编译
g++ -o test test.cpp -std=c++11
导致:
bla
就像它应该做的那样。用
编译它clang++ -o test test.cpp -std=c++11 -stdlib=libc++
导致:
zsh: illegal hardware instruction ./test
并用它编译
clang++ -o test test.cpp -std=c++11 -stdlib=stdlibc++
还导致:
zsh: illegal hardware instruction ./test
Clang/GCC 版本:
clang version 3.2 (tags/RELEASE_32/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
gcc version 4.7.2 (Gentoo 4.7.2-r1 p1.5, pie-0.5.5)
任何人有什么建议是怎么回事?
提前致谢!
【问题讨论】:
-
我会说这是 Clang 中的一个错误
-
仅供参考,有关ud2 and clang的更多信息