I compiled tinyxml2 with the following changes to CMakeLists.txt:
-------------------------------------------------- ------------------------------------------
set (CMAKE_C_COMPILER "/ usr / local / bin / clang10")
set (CMAKE_CXX_COMPILER "/ usr / local / bin / clang ++ 10")
add_compile_options (-g)
add_compile_options (-fsanitize = address, undefined, integer, alignment, bool, builtin, bounds, enum, function, nonnull-attribute, null, object-size, pointer-overflow, return, returns-nonnull-attribute, unreachable, vla-bound , vptr)
set_source_files_properties (tinyxml2.cpp tinyxml2.h
PROPERTIES COMPILE_FLAGS -fsanitize = address, undefined, integer, alignment, bool, builtin, bounds, enum, function, nonnull-attribute, null, object-size, pointer-overflow, return, returns-nonnull-attribute, unreachable, vla-bound , vptr)
TARGET_LINK_LIBRARIES (tinyxml2 /usr/local/llvm10/lib/clang/10.0.0/lib/freebsd/libclang_rt.asan-x86_64.a /usr/local/llvm10/lib/clang/10.0.0/lib/freebsd/libang asan_cxx-x86_64.a /usr/local/llvm10/lib/clang/10.0.0/lib/freebsd/libclang_rt.ubsan_standalone-x86_64.a /usr/local/llvm10/lib/clang/10.0.0/lib/freebsd/ libclang_rt.ubsan_standalone_cxx-x86_64.a -lpthread)
-------------------------------------------------- ------------------------------------------
(Sorry for the dirty code.)
And launched the xmltest utility:
-------------------------------------------------- ------------------------------------------
/home/qqq/17_tinyxml2/tinyxml2-master/tinyxml2.cpp:237:37: runtime error: implicit conversion from type 'char' of value -48 (8-bit, signed) to type 'unsigned char' changed the value to 208 (8-bit, unsigned)
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/qqq/17_tinyxml2/tinyxml2-master/tinyxml2.cpp:237:37 in
/home/qqq/17_tinyxml2/tinyxml2-master/tinyxml2.cpp:243:40: runtime error: implicit conversion from type 'char' of value -96 (8-bit, signed) to type 'unsigned char' changed the value to 160 (8-bit, unsigned)
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/qqq/17_tinyxml2/tinyxml2-master/tinyxml2.cpp:243:40 in
/home/qqq/17_tinyxml2/tinyxml2-master/tinyxml2.cpp:1912:39: runtime error: implicit conversion from type 'char' of value -48 (8-bit, signed) to type 'unsigned char' changed the value to 208 (8-bit, unsigned)
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/qqq/17_tinyxml2/tinyxml2-master/tinyxml2.cpp:1912:39 in
-------------------------------------------------- ------------------------------------------
Also, the comparison between size_t max and the actual file size is done
as an unsigned long long, since that type is guaranteed to be at least
64 bits, even on a 32-bit architecture.
The `clean` doesn't appear to serve a purpose. Make already does
dependency tracking, so if files are out of date they will be rebuilt.
The `clean` rule does however cause problems when the test executable
already exists. In that case it will delete outputs, including the test
executable, and then fail. By the time the test executable was deleted,
it was already determined that it was up to date, and so does not get
rebuilt. You end up having to run the command twice, each time seesawing
between deleting outputs or generating outputs and running the tests.