diff --git a/CMakeLists.txt b/CMakeLists.txt index 70563cea2..270e946fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -95,6 +95,21 @@ if( ) endif() + +# GCC and Clang have horrendous Debug builds when using SIMD. +# A common fix is to use '-Og' instead. +# bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54412 +if( + (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR + CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + AND CMAKE_BUILD_TYPE STREQUAL "Debug" +) + simdjson_add_props( + target_compile_options PRIVATE + -Og + ) +endif() + if(SIMDJSON_ENABLE_THREADS) find_package(Threads REQUIRED) simdjson_add_props(target_link_libraries PUBLIC Threads::Threads) diff --git a/tests/dom/random_string_number_tests.cpp b/tests/dom/random_string_number_tests.cpp index 4c2d3f37a..0fff15fbb 100644 --- a/tests/dom/random_string_number_tests.cpp +++ b/tests/dom/random_string_number_tests.cpp @@ -140,7 +140,7 @@ bool tester(int seed, size_t volume) { std::vector buffer(1024); // large buffer (can't overflow) simdjson::dom::parser parser; RandomEngine rand(seed); - double result; + double result{}; for (size_t i = 0; i < volume; i++) { if((i%100000) == 0) { std::cout << "."; std::cout.flush(); } size_t length = build_random_string(rand, buffer.data()); diff --git a/tools/jsonstats.cpp b/tools/jsonstats.cpp index 321b4f047..af0ef3ceb 100644 --- a/tools/jsonstats.cpp +++ b/tools/jsonstats.cpp @@ -123,7 +123,7 @@ void recurse(simdjson::dom::element element, stat_t &s, size_t depth) { if (element.is()) { s.integer_count++; // because an int can be sometimes represented as a double, we // to check whether it is an integer first!!! - int64_t v; + int64_t v{}; error = element.get(v); SIMDJSON_ASSUME(!error); if((v >= std::numeric_limits::min()) and (v <= std::numeric_limits::max()) ) { @@ -138,7 +138,7 @@ void recurse(simdjson::dom::element element, stat_t &s, size_t depth) { } else if (element.is()) { s.float_count++; } else if (element.is()) { - bool v; + bool v{}; error = element.get(v); SIMDJSON_ASSUME(!error); if (v) {