From ef2beaea34cca0c4e31b9f9a8463e36ca2938d02 Mon Sep 17 00:00:00 2001 From: yhirose Date: Sat, 18 Jul 2026 20:08:33 -0400 Subject: [PATCH] Fix MSVC C4146 warning for unsigned types in from_chars The from_chars template is instantiated with unsigned types (e.g. uint64_t for Content-Length), where unary minus on `result` triggers MSVC warning C4146, failing the 32-bit build under warnings-as-errors. Use `T(0) - result`, which yields the identical two's-complement value without the warning. --- httplib.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httplib.h b/httplib.h index e2e6428..261790b 100644 --- a/httplib.h +++ b/httplib.h @@ -696,7 +696,7 @@ inline from_chars_result from_chars(const char *first, const char *last, return {first, std::errc::invalid_argument}; } - value = negative ? -result : result; + value = negative ? T(0) - result : result; return {p, std::errc{}}; }