From 9921531fa476556e80e0c3d847cb83f0245353d1 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov <2536374+asmorkalov@users.noreply.github.com> Date: Sat, 8 Nov 2025 17:07:36 +0300 Subject: [PATCH] Merge pull request #27976 from asmorkalov:as/size_t_fix_win32 Fixed ptrdiff_t cast on windows 32-bit #27976 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake --- modules/imgcodecs/src/bitstrm.cpp | 2 +- modules/imgcodecs/src/utils.cpp | 7 ------- modules/imgcodecs/src/utils.hpp | 1 - 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/modules/imgcodecs/src/bitstrm.cpp b/modules/imgcodecs/src/bitstrm.cpp index 12d9c1bcae..a7e6380dfb 100644 --- a/modules/imgcodecs/src/bitstrm.cpp +++ b/modules/imgcodecs/src/bitstrm.cpp @@ -153,7 +153,7 @@ void RBaseStream::setPos( int64_t pos ) int64_t RBaseStream::getPos() { CV_Assert(isOpened()); - int64_t pos = validateToInt64((m_current - m_start) + m_block_pos); + int64_t pos = static_cast((m_current - m_start) + m_block_pos); CV_Assert(pos >= m_block_pos); // overflow check CV_Assert(pos >= 0); // overflow check return pos; diff --git a/modules/imgcodecs/src/utils.cpp b/modules/imgcodecs/src/utils.cpp index cfbd62b7bc..41fd9f5041 100644 --- a/modules/imgcodecs/src/utils.cpp +++ b/modules/imgcodecs/src/utils.cpp @@ -51,13 +51,6 @@ int validateToInt(size_t sz) return valueInt; } -int64_t validateToInt64(ptrdiff_t sz) -{ - int64_t valueInt = static_cast(sz); - CV_Assert((ptrdiff_t)valueInt == sz); - return valueInt; -} - #define SCALE 14 #define cR (int)(0.299*(1 << SCALE) + 0.5) #define cG (int)(0.587*(1 << SCALE) + 0.5) diff --git a/modules/imgcodecs/src/utils.hpp b/modules/imgcodecs/src/utils.hpp index f2649f0ecd..95deebde31 100644 --- a/modules/imgcodecs/src/utils.hpp +++ b/modules/imgcodecs/src/utils.hpp @@ -45,7 +45,6 @@ namespace cv { int validateToInt(size_t step); -int64_t validateToInt64(ptrdiff_t step); template static inline size_t safeCastToSizeT(const _Tp v_origin, const char* msg)