This fixes issue 42.

This commit is contained in:
Daniel Lemire 2020-11-08 11:05:52 -05:00
parent b4ea262021
commit 278882dd58
4 changed files with 27 additions and 3 deletions

View file

@ -12,10 +12,17 @@ option(FAST_DOUBLE_PARSER_SANITIZE "Sanitize addresses" OFF)
set(headers include/fast_double_parser.h)
set(unit_src tests/unit.cpp)
set(bogus_src tests/bogus.cpp)
set(rebogus_src tests/bogus.cpp)
set(benchmark_src benchmarks/benchmark.cpp)
add_executable(unit ${unit_src})
add_library(fast_double_parser INTERFACE)
target_include_directories(fast_double_parser INTERFACE include/)
add_executable(unit ${unit_src} ${bogus_src} ${rebogus_src})
if(FAST_DOUBLE_PARSER_SANITIZE)
target_compile_options(unit PUBLIC -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined -fno-sanitize-recover=all)
target_link_options(unit PUBLIC -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined -fno-sanitize-recover=all)
@ -25,7 +32,10 @@ if(FAST_DOUBLE_PARSER_SANITIZE)
endif()
endif()
target_include_directories(unit PUBLIC include)
target_link_libraries(unit PUBLIC fast_double_parser)
enable_testing()
add_test(unit unit)

View file

@ -142,7 +142,7 @@ static inline uint64_t _umul128(uint64_t ab, uint64_t cd, uint64_t *hi) {
// We need a backup on old systems.
// credit: https://stackoverflow.com/questions/28868367/getting-the-high-part-of-64-bit-integer-multiplication
uint64_t Emulate64x64to128(uint64_t& r_hi, const uint64_t x, const uint64_t y) {
really_inline uint64_t Emulate64x64to128(uint64_t& r_hi, const uint64_t x, const uint64_t y) {
const uint64_t x0 = (uint32_t)x, x1 = x >> 32;
const uint64_t y0 = (uint32_t)y, y1 = y >> 32;
const uint64_t p11 = x1 * y1, p01 = x0 * y1;

7
tests/bogus.cpp Normal file
View file

@ -0,0 +1,7 @@
#include "fast_double_parser.h"
// To detect issues such as
// https://github.com/lemire/fast_double_parser/issues/42
fast_double_parser::value128 my_full_multiplication(uint64_t value1, uint64_t value2) {
return fast_double_parser::full_multiplication(value1, value2);
}

7
tests/rebogus.cpp Normal file
View file

@ -0,0 +1,7 @@
#include "fast_double_parser.h"
// To detect issues such as
// https://github.com/lemire/fast_double_parser/issues/42
fast_double_parser::value128 my_other_full_multiplication(uint64_t value1, uint64_t value2) {
return fast_double_parser::full_multiplication(value1, value2);
}