From 91a852d3fd1f79816efc7c249a7b964f1411f11d Mon Sep 17 00:00:00 2001 From: Alexander Shabalin Date: Thu, 17 Jun 2021 13:25:09 +0300 Subject: [PATCH] Fix integer conversion on 32-bit --- kotlin-native/runtime/src/main/cpp/MemoryUsageInfo.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kotlin-native/runtime/src/main/cpp/MemoryUsageInfo.cpp b/kotlin-native/runtime/src/main/cpp/MemoryUsageInfo.cpp index 1f91f5a521c..709087cd464 100644 --- a/kotlin-native/runtime/src/main/cpp/MemoryUsageInfo.cpp +++ b/kotlin-native/runtime/src/main/cpp/MemoryUsageInfo.cpp @@ -58,6 +58,10 @@ size_t kotlin::GetPeakResidentSetSizeBytes() noexcept { extern "C" RUNTIME_NOTHROW KLong Kotlin_MemoryUsageInfo_getPeakResidentSetSizeBytes() { auto result = kotlin::GetPeakResidentSetSizeBytes(); - auto boundedResult = std::min(result, std::numeric_limits::max()); - return static_cast(boundedResult); + // TODO: Need a common implementation for such conversions. + if constexpr (sizeof(decltype(result)) >= sizeof(KLong)) { + return static_cast(std::min(result, std::numeric_limits::max())); + } else { + return std::min(result, std::numeric_limits::max()); + } }