Skip to content

Commit fedbd6c

Browse files
Fix error C2397: conversion from 'const int' to 'unsigned __int64' requires a narrowing conversion
Except for iterators with exotic difference types: For x64 algorithms, `_Diff` is naturally 64-bit, so `is_same_v<_Udiff, uint64_t>` is naturally taken. But for x86 algorithms, `_Diff` is naturally 32-bit. If the URBG is 32-bit (or smaller), then `_Udiff` will be `uint32_t`, and the `else` branch will be taken. In that case, the error correctly complains that we're using braces to convert from signed `_Diff _Index` to unsigned `_Uprod`, which is narrowing. We should directly `static_cast` instead.
1 parent bb03a9e commit fedbd6c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

stl/inc/algorithm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6133,7 +6133,7 @@ private:
61336133
const auto _Low = _Base128::_UMul128(_Ret, static_cast<_Udiff>(_Index), _High);
61346134
return _Uprod{_Low, _High};
61356135
} else {
6136-
return _Uprod{_Ret} * _Uprod{_Index};
6136+
return _Uprod{_Ret} * static_cast<_Uprod>(_Index);
61376137
}
61386138
}
61396139

0 commit comments

Comments
 (0)