1
消毒クランの「未定義」を使用している場合、このコードが有効になって打ち鳴らすの「未定義の動作」消毒剤と罰金コンパイル:未定義シンボル
➜ ~ cat test.cc
#include <iostream>
int main(int argc, char **argv) {
// Won't compile if next line will be uncommented!
// std::cout << "Hello, World!" << std::endl;
int k = 0x7fffffff;
k += argc;
return 0;
}
➜ ~ clang++ -fsanitize=address -fsanitize=undefined test.cc
をしかし、私はそれが爆発述べ行コメントを解除する場合:
~ clang++ -fsanitize=address -fsanitize=undefined test.cc
Undefined symbols for architecture x86_64:
"___ubsan_handle_dynamic_type_cache_miss", referenced from:
_main in test-5f28d3.o
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::endl<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) in test-5f28d3.o
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in test-5f28d3.o
std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> > std::__1::__pad_and_output<char, std::__1::char_traits<char> >(std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >, char const*, char const*, char const*, std::__1::ios_base&, char) in test-5f28d3.o
"___ubsan_vptr_type_cache", referenced from:
_main in test-5f28d3.o
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::endl<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) in test-5f28d3.o
std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) in test-5f28d3.o
std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> > std::__1::__pad_and_output<char, std::__1::char_traits<char> >(std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >, char const*, char const*, char const*, std::__1::ios_base&, char) in test-5f28d3.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
クランバージョンを:
➜ ~ clang --version
Apple LLVM version 8.0.0 (clang-800.0.38)
Target: x86_64-apple-darwin15.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
詳細コンパイラ出力はhereです。
私は間違っていますか?