Skip to content

Fix CodeQL warnings after _wsetlocale() changes#6179

Merged
StephanTLavavej merged 2 commits intomicrosoft:mainfrom
StephanTLavavej:codeql
Mar 27, 2026
Merged

Fix CodeQL warnings after _wsetlocale() changes#6179
StephanTLavavej merged 2 commits intomicrosoft:mainfrom
StephanTLavavej:codeql

Conversation

@StephanTLavavej
Copy link
Copy Markdown
Member

Fixes internal VSO-2845667 and VSO-2845668.

CodeQL is emitting SM02986: cpp/incorrect-string-type-conversion, saying "Conversion from char * to __wchar_t *. Use of invalid string can lead to undefined behavior." for <xlocinfo> and "Conversion from const char * to const __wchar_t *. Use of invalid string can lead to undefined behavior." for locale0.cpp.

These warnings are desirable, we're just doing something that's intentionally sketchy-looking but correct. Accordingly, I'm adding suppression comments, citing #5781 where these changes were introduced.

CodeQL appears to warn only when reinterpret_casting from char* to wchar_t*, not the reverse (possibly because casts to char* are very common). Just in case, I am additionally adding the suppression to the reinterpret_cast<char*> where we actually store the wide string.

@StephanTLavavej StephanTLavavej added the enhancement Something can be improved label Mar 23, 2026
@StephanTLavavej StephanTLavavej requested a review from a team as a code owner March 23, 2026 21:24
@github-project-automation github-project-automation Bot moved this to Initial Review in STL Code Reviews Mar 23, 2026
@StephanTLavavej StephanTLavavej moved this from Initial Review to Final Review in STL Code Reviews Mar 23, 2026
@StephanTLavavej StephanTLavavej moved this from Final Review to Ready To Merge in STL Code Reviews Mar 24, 2026
@StephanTLavavej
Copy link
Copy Markdown
Member Author

I'm mirroring this to the MSVC-internal repo. Please notify me if any further changes are pushed, otherwise no action is required.

@StephanTLavavej StephanTLavavej moved this from Ready To Merge to Merging in STL Code Reviews Mar 26, 2026
@StephanTLavavej StephanTLavavej merged commit 49a58a1 into microsoft:main Mar 27, 2026
49 checks passed
@StephanTLavavej StephanTLavavej deleted the codeql branch March 27, 2026 04:26
@github-project-automation github-project-automation Bot moved this from Merging to Done in STL Code Reviews Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Something can be improved

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants