From 088b3676ab59e9894438a14a20dcea680dcaf3d6 Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Tue, 3 Oct 2023 15:13:34 +0800 Subject: [PATCH] Fix narrowing --- stl/inc/random | 7 ++++--- tests/tr1/tests/random4/test.cpp | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/stl/inc/random b/stl/inc/random index 75ee59fb74b..377d5cb8095 100644 --- a/stl/inc/random +++ b/stl/inc/random @@ -1519,12 +1519,13 @@ private: _EXPORT_STD template class discard_block_engine // discard_block_engine compound engine - : public conditional_t<_Px <= INT_MAX, discard_block<_Engine, _Px, _Rx>, _Discard_block_base<_Engine, _Px, _Rx>> { + : public conditional_t<_Px <= INT_MAX, discard_block<_Engine, static_cast(_Px), static_cast(_Rx)>, + _Discard_block_base<_Engine, _Px, _Rx>> { public: static_assert(0 < _Rx && _Rx <= _Px, "invalid template argument for discard_block_engine"); - using _Mybase = - conditional_t<_Px <= INT_MAX, discard_block<_Engine, _Px, _Rx>, _Discard_block_base<_Engine, _Px, _Rx>>; + using _Mybase = conditional_t<_Px <= INT_MAX, discard_block<_Engine, static_cast(_Px), static_cast(_Rx)>, + _Discard_block_base<_Engine, _Px, _Rx>>; using result_type = typename _Engine::result_type; static constexpr size_t block_size = _Px; diff --git a/tests/tr1/tests/random4/test.cpp b/tests/tr1/tests/random4/test.cpp index 0443f3c6ddf..b9ad14f27e8 100644 --- a/tests/tr1/tests/random4/test.cpp +++ b/tests/tr1/tests/random4/test.cpp @@ -231,7 +231,7 @@ static void tsubtract() { } static void tdiscard() { - int i; + STD size_t i; typedef STD subtract_with_carry_engine rng_base_t; typedef STD discard_block_engine rng_t; CHECK_INT(rng_t::block_size, 223);