Potential sign-extending cast when a zero-extending cast was intended
Open
- 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
Assessment
This issue has not been assessed yet.