Skip to content

Fix static analysis warning C4146 in caltest.cpp - #193

Open
Hanumant Shinde (therealhshinde) wants to merge 2 commits into
masterfrom
user/hashinde/164343-c4146
Open

Fix static analysis warning C4146 in caltest.cpp#193
Hanumant Shinde (therealhshinde) wants to merge 2 commits into
masterfrom
user/hashinde/164343-c4146

Conversation

@therealhshinde

@therealhshinde Hanumant Shinde (therealhshinde) commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Fix

Replace two -2147483648 test inputs in caltest.cpp with INT32_MIN. MSVC parses the decimal magnitude as unsigned before applying unary minus, producing C4146; INT32_MIN expresses the intended signed boundary directly without changing test behavior.

The change also records the fix as permanent Microsoft patch 030-MSFT-Patch-Fix_MSVC_C4146_caltest.patch so it survives future upstream ICU source imports.

Internal tracking: AB#164343

Compiler verification

Before

caltest.cpp(5928,37): warning C4146: unary minus operator applied to unsigned type, result still unsigned
caltest.cpp(6070,30): warning C4146: unary minus operator applied to unsigned type, result still unsigned
996 Warning(s), 0 Error(s)

After

No C4146 findings
994 Warning(s), 0 Error(s)
  • Exactly the two target warning signatures were removed.
  • No new warning signatures were introduced.

Test verification

  • Built intltest Release x64 with Visual Studio 2022/MSVC.
  • Ran the complete format/CalendarTest suite: all tests passed.
  • Verified patch 030 applies cleanly to the pre-fix commit and produces the exact source blob from the fix commit.

Hanumant Shinde added 2 commits August 13, 2026 15:01
Use INT32_MIN for the two signed 32-bit minimum test inputs so MSVC does not parse the magnitude as unsigned before applying unary minus.

Bug: microsoft/OS#164343

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 66c0022c-72ad-4331-9459-b0c73c068072
Preserve the MSVC warning fix across future upstream ICU source imports.

Bug: microsoft/OS#164343

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 66c0022c-72ad-4331-9459-b0c73c068072
@therealhshinde

Copy link
Copy Markdown
Collaborator Author

@microsoft-github-policy-service agree company="Microsoft"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant