使用clang从boost版本1.64运行gzip.hpp代码将给出以下消息:
path/to/boost/1_64_0/include/boost/iostreams/filter/gzip.hpp:674:16: runtime error: implicit conversion from type 'int' of value 139 (32-bit, signed) to type 'char' changed the value to -117 (8-bit, signed)
#0 0x7fed40b77bc2 in boost::iostreams::basic_gzip_compressor<std::allocator<char> >::basic_gzip_compressor(boost::iostreams::gzip_params const&, long)我想用一个抑制文件来抑制这个。对于其他警告,这是有效的:
unsigned-integer-overflow:path/to/boost/*在这种情况下,我认为这应该是可行的。
implicit-integer-sign-change:/lfs/vlsi/tools/boost/*但它会在运行时发出
UndefinedBehaviorSanitizer: failed to parse suppressions这个萨纳蒂泽旗的正确名称是什么?
另见:https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#runtime-suppressions
来自https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#available-checks
-fsanitize=隐式-整数-符号更改:整数类型之间的隐式转换,如果这改变了值的符号。也就是说,如果原始值为负值,新值为正(或零),或原始值为正,而新值为负值。这种消毒剂所遇到的问题不是未定义的行为,而是经常是无意的。
发布于 2019-01-28 08:03:15
我在llvm -dev 邮寄名单上得到了帮助
TLDR:警告类型的名称不是implicit-integer-sign-change,而是implicit-integer-truncation,可以按预期进行抑制。可以使用export UBSAN_OPTIONS=report_error_type=1查找错误类型的名称。
发布于 2018-11-25 10:56:56
根据您正在阅读的这些文档,您可以使用以下步骤来禁止UBSan消息:
with__attribute__((no_sanitize("undefined")))¶ 禁用 您可以在此属性中禁用对特定函数的UBSan检查-fsanitize=标志的所有值,例如,如果函数故意包含可能的有符号整数溢出,则可以使用UBSan。 此属性可能不受其他编译器的支持,因此请考虑与#ifdefined(clang).一起使用它。
因此,您应该做的是:检查同一页中的文档,查看您想要抑制的内容,并将其与use__attribute__((no_sanitize("here_goes_checks_you_want_to_suppress"))).或use__attribute__((no_sanitize("undefined"))).结合起来,从而完全禁用UBSan。
除此之外,似乎UBSan正在抛出一个有符号整数溢出,而您正试图抑制无符号整数溢出。
链接:https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
https://stackoverflow.com/questions/53466501
复制相似问题