Werfen Sie einen Blick auf dieses Stück Code:Seltsam Clang Verhalten
#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;
}
es mit
g++ -o test test.cpp -std=c++11
führt zu kompilieren:
bla
wie es tun sollten. Kompilieren mit
clang++ -o test test.cpp -std=c++11 -stdlib=libc++
führt zu:
zsh: illegal hardware instruction ./test
Und es mit
clang++ -o test test.cpp -std=c++11 -stdlib=stdlibc++
Kompilieren führt auch zu:
zsh: illegal hardware instruction ./test
Clang/GCC-Versionen:
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)
Wer irgendwelche Vorschläge was schief geht?
Vielen Dank im Voraus!
Ich würde sagen, das ist ein Bug in Clang –
FYI, mehr Informationen über [ud2 und kling] (http://stackoverflow.com/q/26309300/1708801) –