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()); + } }