This is an automated email from the ASF dual-hosted git repository.

leginee pushed a commit to branch bazel-migration
in repository https://gitbox.apache.org/repos/asf/openoffice.git

commit 3db6ef0622880653d263d925fb5b35d8bb8c8f2f
Author: Peter Kovacs <[email protected]>
AuthorDate: Tue Jul 21 12:06:27 2026 +0200

    sal: fix std::min type ambiguity in osl/w32 profile.cxx on x64
    
    getLine() computes `min(pChr - pFile->m_pReadPtr, MaxLen)` where the
    pointer difference is ptrdiff_t (64-bit on x64) while MaxLen is int.
    When `min` resolves to std::min -- which it does whenever NOMINMAX is
    defined, suppressing the <windows.h> min/max macros -- the two mismatched
    argument types make template argument deduction ambiguous:
    
      error C2782: 'const _Ty &std::min(const _Ty &,const _Ty &)' :
      template parameter '_Ty' is ambiguous  (could be 'int' or '__int64')
    
    On x86 both operands are int (ptrdiff_t == int), so it compiled; only the
    x64 pointer-width change exposes it.  Disambiguate by casting the pointer
    difference to int (the read buffer is small, so the value always fits).
    The cast is a no-op on x86 and is correct whether `min` is the
    <windows.h> macro or std::min, so it is safe for every build.
    
    Co-Authored-By: Claude Opus 4.8 <[email protected]>
    (cherry picked from commit 0f32c8f679d1f68cd05b9bc1513c7819376bb492)
---
 main/sal/osl/w32/profile.cxx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/main/sal/osl/w32/profile.cxx b/main/sal/osl/w32/profile.cxx
index 84f0458a06..569fa6da9e 100644
--- a/main/sal/osl/w32/profile.cxx
+++ b/main/sal/osl/w32/profile.cxx
@@ -1405,7 +1405,7 @@ static sal_Bool getLine(osl_TFile* pFile, const sal_Char 
*pszLine, int MaxLen)
                         (pChr < (pFile->m_ReadBuf + sizeof(pFile->m_ReadBuf) - 
1));
                         pChr++);
 
-               Max = min(pChr - pFile->m_pReadPtr, MaxLen);
+               Max = min(static_cast<int>(pChr - pFile->m_pReadPtr), MaxLen);
                memcpy(pLine, pFile->m_pReadPtr, Max);
                MaxLen -= Max;
                pLine  += Max;

Reply via email to