dotnet / dotnet/wpf

Potential sign-extending cast when a zero-extending cast was intended

Open
#11,276 1 comment 1 reaction 1 assignee Claimed by @ThomasGoulet73 View on GitHub
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

Testing out some new CodeQL rules locally. One of them flagged a line in WPF that appears suspicious.

https://github.com/dotnet/wpf/blob/1e89865cc87be0daf939d00b1b2667cd485efa93/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/CommonXSendMessage.cs#L1535

This expression always returns **false** because an explicit cast from `int` -> `ulong` is actually treated by the compiler as `int` -> `long` -> `ulong` (note the intermediate implicit sign-extending cast).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.