This commit is contained in:
HedgehogInTheCPP 2026-08-21 12:38:01 +03:00
commit 42eecf4205
9 changed files with 18 additions and 18 deletions

View File

@ -14,4 +14,4 @@ jobs:
python3 ./script/amalgamate.py > build/fast_float/fast_float.h &&
cp tests/string_test.cpp build/ &&
cd build &&
g++ string_test.cpp
g++ -Werror=old-style-cast string_test.cpp

View File

@ -113,10 +113,10 @@ int main() {
buf.reserve(N * ip_size);
for (size_t i = 0; i < N; ++i) {
uint8_t a = (uint8_t)dist(rng);
uint8_t b = (uint8_t)dist(rng);
uint8_t c = (uint8_t)dist(rng);
uint8_t d = (uint8_t)dist(rng);
uint8_t a = static_cast<uint8_t>(dist(rng));
uint8_t b = static_cast<uint8_t>(dist(rng));
uint8_t c = static_cast<uint8_t>(dist(rng));
uint8_t d = static_cast<uint8_t>(dist(rng));
std::string ip_line = make_ip_line(a, b, c, d);
ip_line.resize(ip_size, ' '); // pad to fixed size
buf.append(ip_line);
@ -132,7 +132,7 @@ int main() {
std::string buffer(ip_size * N, ' ');
pretty_print(volume, bytes, "memcpy baseline", counters::bench([&]() {
std::memcpy((char *)buffer.data(), buf.data(), bytes);
std::memcpy(buffer.data(), buf.data(), bytes);
}));
pretty_print(volume, bytes, "just_seek_ip_end (no parse)",
@ -143,7 +143,7 @@ int main() {
int ok = 0;
for (size_t i = 0; i < N; ++i) {
const char *q = seek_ip_end(p, pend);
sum += (uint32_t)(q - p);
sum += static_cast<uint32_t>(q - p);
p += ip_size;
}
sink += sum;

View File

@ -75,7 +75,7 @@ int main() {
buffer.reserve(N * 6); // up to 5 digits + delimiter
for (size_t i = 0; i < N; ++i) {
uint16_t val = (uint16_t)dist(rng);
uint16_t val = static_cast<uint16_t>(dist(rng));
expected.push_back(val);
std::string s = std::to_string(val);
buffer.append(s);

View File

@ -623,8 +623,8 @@ struct bigint : pow5_tables<> {
// Work around clang bug https://godbolt.org/z/zedh7rrhc
// This is similar to https://github.com/llvm/llvm-project/issues/47746,
// except the workaround described there don't work here
FASTFLOAT_TRY(small_mul(
vec, limb(((void)small_power_of_5[0], small_power_of_5[exp]))));
FASTFLOAT_TRY(small_mul(vec, limb((static_cast<void>(small_power_of_5[0]),
small_power_of_5[exp]))));
}
return true;

View File

@ -403,8 +403,8 @@ negative_digit_comp(bigint &real_digits, adjusted_mantissa am,
round<T>(am, [ord](adjusted_mantissa &a, am_pow_t shift) {
round_nearest_tie_even(
a, shift, [ord](bool is_odd, bool _, bool __) -> bool {
(void)_; // not needed, since we've done our comparison
(void)__; // not needed, since we've done our comparison
static_cast<void>(_); // not needed, since we've done our comparison
static_cast<void>(__); // not needed, since we've done our comparison
if (ord > 0) {
return true;
} else if (ord < 0) {

View File

@ -49,7 +49,7 @@ function(fast_float_add_cpp_test TEST_NAME)
target_compile_options(${TEST_NAME} PUBLIC /EHsc)
endif()
if(NOT WIN32)
target_compile_options(${TEST_NAME} PUBLIC -Werror -Wall -Wextra -Weffc++)
target_compile_options(${TEST_NAME} PUBLIC -Werror -Wall -Wextra -Weffc++ -Wold-style-cast)
target_compile_options(${TEST_NAME} PUBLIC -Wsign-compare -Wshadow -Wwrite-strings -Wpointer-arith -Winit-self -Wconversion -Wsign-conversion)
endif()
target_link_libraries(${TEST_NAME} PUBLIC fast_float supplemental-data)

View File

@ -1061,7 +1061,7 @@ void basic_test(float val) {
do { \
constexpr int verify_comptime_var = \
(basic_test<Diag::comptime>(__VA_ARGS__), 0); \
(void)verify_comptime_var; \
static_cast<void>(verify_comptime_var); \
} while (false)
#define verify_options_runtime(...) \
@ -1073,7 +1073,7 @@ void basic_test(float val) {
do { \
constexpr int verify_options_comptime_var = \
(basic_test<Diag::comptime>(__VA_ARGS__, options), 0); \
(void)verify_options_comptime_var; \
static_cast<void>(verify_options_comptime_var); \
} while (false)
#if defined(FASTFLOAT_CONSTEXPR_TESTS)

View File

@ -61,7 +61,7 @@ template <typename T> char *to_string(T d, char *buffer) {
}
void strtof_from_string(char const *st, float &d) {
char *pr = (char *)st;
char *pr = const_cast<char *>(st);
#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MINGW64__) || \
defined(sun) || defined(__sun)
d = cygwin_strtof_l(st, &pr);

View File

@ -125,7 +125,7 @@ template <typename T> bool test() {
template <typename T> void strtod_from_string(std::string const &st, T &d);
template <> void strtod_from_string(std::string const &st, double &d) {
char *pr = (char *)st.c_str();
char *pr = const_cast<char *>(st.c_str());
#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MINGW64__) || \
defined(sun) || defined(__sun)
d = cygwin_strtod_l(pr, &pr);
@ -142,7 +142,7 @@ template <> void strtod_from_string(std::string const &st, double &d) {
}
template <> void strtod_from_string(std::string const &st, float &d) {
char *pr = (char *)st.c_str();
char *pr = const_cast<char *>(st.c_str());
#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MINGW64__) || \
defined(sun) || defined(__sun)
d = cygwin_strtof_l(st.c_str(), &pr);