diff --git a/.github/workflows/ubuntu20-checkperf.yml b/.github/workflows/ubuntu20-checkperf.yml index 9c29bdf1b..b5e4a38f8 100644 --- a/.github/workflows/ubuntu20-checkperf.yml +++ b/.github/workflows/ubuntu20-checkperf.yml @@ -24,6 +24,6 @@ jobs: run: | mkdir build && cd build && - cmake -DSIMDJSON_GOOGLE_BENCHMARKS=ON -DSIMDJSON_BUILD_STATIC=ON -DCMAKE_INSTALL_PREFIX:PATH=destination .. && + cmake -DCMAKE_CXX_FLAGS="-Werror=old-style-cast -pedantic -Wpedantic" -DSIMDJSON_GOOGLE_BENCHMARKS=ON -DSIMDJSON_BUILD_STATIC=ON -DCMAKE_INSTALL_PREFIX:PATH=destination .. && cmake --build . --target checkperf && ctest --output-on-failure -R checkperf diff --git a/benchmark/benchmarker.h b/benchmark/benchmarker.h index bb9c42a29..ccbc5b631 100644 --- a/benchmark/benchmarker.h +++ b/benchmark/benchmarker.h @@ -321,7 +321,7 @@ struct benchmarker { allocate_stage << allocate_count; // Run it once to get hot buffers if(hotbuffers) { - auto result = parser.parse((const uint8_t *)json.data(), json.size()); + auto result = parser.parse(reinterpret_cast(json.data()), json.size()); if (result.error()) { exit_error(string("Failed to parse ") + filename + string(":") + error_message(result.error())); } @@ -331,7 +331,7 @@ struct benchmarker { // Stage 1 (find structurals) collector.start(); - error = parser.implementation->stage1((const uint8_t *)json.data(), json.size(), false); + error = parser.implementation->stage1(reinterpret_cast(json.data()), json.size(), false); event_count stage1_count = collector.end(); stage1 << stage1_count; if (error) { @@ -367,7 +367,7 @@ struct benchmarker { void run_loop(size_t iterations) { dom::parser parser; - auto firstresult = parser.parse((const uint8_t *)json.data(), json.size()); + auto firstresult = parser.parse(reinterpret_cast(json.data()), json.size()); if (firstresult.error()) { exit_error(string("Failed to parse ") + filename + string(":") + error_message(firstresult.error())); } @@ -375,7 +375,7 @@ struct benchmarker { collector.start(); // some users want something closer to "number of documents per second" for(size_t i = 0; i < iterations; i++) { - auto result = parser.parse((const uint8_t *)json.data(), json.size()); + auto result = parser.parse(reinterpret_cast(json.data()), json.size()); if (result.error()) { exit_error(string("Failed to parse ") + filename + string(":") + error_message(result.error())); } @@ -446,7 +446,7 @@ struct benchmarker { void print(bool tabbed_output) const { if (tabbed_output) { - char* filename_copy = (char*)malloc(strlen(filename)+1); + char* filename_copy = reinterpret_cast(malloc(strlen(filename)+1)); SIMDJSON_PUSH_DISABLE_WARNINGS SIMDJSON_DISABLE_DEPRECATED_WARNING // Validated CRT_SECURE safe here strcpy(filename_copy, filename); diff --git a/include/simdjson/arm64/simd.h b/include/simdjson/arm64/simd.h index 0a8948962..df4249d00 100644 --- a/include/simdjson/arm64/simd.h +++ b/include/simdjson/arm64/simd.h @@ -115,9 +115,9 @@ simdjson_really_inline int8x16_t make_int8x16_t(int8_t x1, int8_t x2, int8_t x simdjson_really_inline simd8 operator^(const simd8 other) const { return veorq_u8(*this, other); } simdjson_really_inline simd8 bit_andnot(const simd8 other) const { return vbicq_u8(*this, other); } simdjson_really_inline simd8 operator~() const { return *this ^ 0xFFu; } - simdjson_really_inline simd8& operator|=(const simd8 other) { auto this_cast = (simd8*)this; *this_cast = *this_cast | other; return *this_cast; } - simdjson_really_inline simd8& operator&=(const simd8 other) { auto this_cast = (simd8*)this; *this_cast = *this_cast & other; return *this_cast; } - simdjson_really_inline simd8& operator^=(const simd8 other) { auto this_cast = (simd8*)this; *this_cast = *this_cast ^ other; return *this_cast; } + simdjson_really_inline simd8& operator|=(const simd8 other) { auto this_cast = static_cast*>(this); *this_cast = *this_cast | other; return *this_cast; } + simdjson_really_inline simd8& operator&=(const simd8 other) { auto this_cast = static_cast*>(this); *this_cast = *this_cast & other; return *this_cast; } + simdjson_really_inline simd8& operator^=(const simd8 other) { auto this_cast = static_cast*>(this); *this_cast = *this_cast ^ other; return *this_cast; } simdjson_really_inline Mask operator==(const simd8 other) const { return vceqq_u8(*this, other); } @@ -284,9 +284,9 @@ simdjson_really_inline int8x16_t make_int8x16_t(int8_t x1, int8_t x2, int8_t x // only the first pop1 bytes from the first 8 bytes, and then // it fills in with the bytes from the second 8 bytes + some filling // at the end. - uint8x16_t compactmask = vld1q_u8((const uint8_t *)(pshufb_combine_table + pop1 * 8)); + uint8x16_t compactmask = vld1q_u8(reinterpret_cast(pshufb_combine_table + pop1 * 8)); uint8x16_t answer = vqtbl1q_u8(pruned, compactmask); - vst1q_u8((uint8_t*) output, answer); + vst1q_u8(reinterpret_cast(output), answer); } template diff --git a/include/simdjson/generic/stringparsing.h b/include/simdjson/generic/stringparsing.h index 0f772d0db..7bc6d4796 100644 --- a/include/simdjson/generic/stringparsing.h +++ b/include/simdjson/generic/stringparsing.h @@ -127,7 +127,7 @@ simdjson_unused simdjson_warn_unused simdjson_really_inline error_code parse_str if (*(src++) != '"') { return STRING_ERROR; } auto end = stringparsing::parse_string(src, current_string_buf_loc); if (!end) { return STRING_ERROR; } - s = std::string_view((const char *)current_string_buf_loc, end-current_string_buf_loc); + s = std::string_view(reinterpret_cast(current_string_buf_loc), end-current_string_buf_loc); current_string_buf_loc = end; return SUCCESS; } diff --git a/include/simdjson/ppc64/simd.h b/include/simdjson/ppc64/simd.h index 51a0bd9ea..f8683bc87 100644 --- a/include/simdjson/ppc64/simd.h +++ b/include/simdjson/ppc64/simd.h @@ -42,17 +42,17 @@ template struct base { return vec_andc(this->value, (__m128i)other); } simdjson_really_inline Child &operator|=(const Child other) { - auto this_cast = (Child *)this; + auto this_cast = static_cast(this); *this_cast = *this_cast | other; return *this_cast; } simdjson_really_inline Child &operator&=(const Child other) { - auto this_cast = (Child *)this; + auto this_cast = static_cast(this); *this_cast = *this_cast & other; return *this_cast; } simdjson_really_inline Child &operator^=(const Child other) { - auto this_cast = (Child *)this; + auto this_cast = static_cast(this); *this_cast = *this_cast ^ other; return *this_cast; } @@ -131,7 +131,7 @@ template struct base8_numeric : base8 { } static simdjson_really_inline simd8 zero() { return splat(0); } static simdjson_really_inline simd8 load(const T values[16]) { - return (__m128i)(vec_vsx_ld(0, (const uint8_t *)values)); + return (__m128i)(vec_vsx_ld(0, reinterpret_cast(values))); } // Repeat 16 values as many times as necessary (usually for lookup tables) static simdjson_really_inline simd8 repeat_16(T v0, T v1, T v2, T v3, T v4, @@ -163,11 +163,11 @@ template struct base8_numeric : base8 { } simdjson_really_inline simd8 &operator+=(const simd8 other) { *this = *this + other; - return *(simd8 *)this; + return *static_cast *>(this); } simdjson_really_inline simd8 &operator-=(const simd8 other) { *this = *this - other; - return *(simd8 *)this; + return *static_cast *>(this); } // Perform a lookup assuming the value is between 0 and 16 (undefined behavior @@ -217,9 +217,9 @@ template struct base8_numeric : base8 { // it fills in with the bytes from the second 8 bytes + some filling // at the end. __m128i compactmask = - vec_vsx_ld(0, (const uint8_t *)(pshufb_combine_table + pop1 * 8)); + vec_vsx_ld(0, reinterpret_cast(pshufb_combine_table + pop1 * 8)); __m128i answer = vec_perm(pruned, (__m128i)vec_splats(0), compactmask); - vec_vsx_st(answer, 0, (__m128i *)(output)); + vec_vsx_st(answer, 0, reinterpret_cast<__m128i *>(output)); } template