1
0
Эх сурвалжийг харах

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.
yhirose 3 долоо хоног өмнө
parent
commit
ef2beaea34
1 өөрчлөгдсөн 1 нэмэгдсэн , 1 устгасан
  1. 1 1
      httplib.h

+ 1 - 1
httplib.h

@@ -696,7 +696,7 @@ inline from_chars_result<T> 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{}};
 }