Skip to content

Commit 9f045ad

Browse files
committed
stdlib: silence truncation warning on Windows
The returned type `std::streamoff` on Windows x64 is a `long long` rather than `int`. This results in a 64-to-32 bit shortening of the value. Use the appropriate type to avoid the truncation. `strlen` returns a unsigned value, but `std::streamoff` is an signed value. Explicitly cast the value to avoid the warning about the implicit signed conversion.
1 parent db8b98b commit 9f045ad

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

stdlib/public/stubs/Stubs.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,9 +473,9 @@ static const char *_swift_stdlib_strtoX_clocale_impl(
473473
ValueStream >> ParsedValue;
474474
*outResult = ParsedValue;
475475

476-
int pos = ValueStream.tellg();
476+
std::streamoff pos = ValueStream.tellg();
477477
if (ValueStream.eof())
478-
pos = strlen(nptr);
478+
pos = static_cast<std::streamoff>(strlen(nptr));
479479
if (pos <= 0)
480480
return nullptr;
481481

0 commit comments

Comments
 (0)