Skip to content

Conversation

@davidwrighton
Copy link
Member

  • This is part of allowing I4 and I to be interchangeable, since some forms of ByRef will devolve to be treated as an I
  • This isn't a fully general purpose fix, but in cases where it is valid code it will make it work.

- This is part of allowing I4 and I to be interchangeable, since some forms of ByRef will devolve to be treated as an I
- This isn't a fully general purpose fix, but in cases where it is valid code it will make it work.
Copilot AI review requested due to automatic review settings December 4, 2025 18:34
@davidwrighton davidwrighton changed the title Fix GitHub_9651 by allowing an I4 to be treated as a ByRef [clr-interp] Fix GitHub_9651 by allowing an I4 to be treated as a ByRef Dec 4, 2025
@github-actions github-actions bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Dec 4, 2025
@davidwrighton davidwrighton removed the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Dec 4, 2025
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @BrzVlad, @janvorli, @kg
See info in area-owners.md if you want to be subscribed.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes GitHub issue #9651 in the CoreCLR interpreter by allowing I4 (int32) values to be implicitly converted to ByRef types on 64-bit systems. The fix addresses a specific scenario where I4 and native int/ByRef can be used interchangeably in valid IL code, particularly when branching logic may assign either an int32 or an address to a native int variable.

Key Changes

  • Modified the type conversion logic in the interpreter compiler to treat I4 to ByRef conversions similar to I4 to I8 (nint) conversions on 64-bit targets
  • This allows IL code patterns where int32 zero and addresses are used interchangeably with native int variables

Copy link
Member

@janvorli janvorli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

@janvorli janvorli merged commit 5d57207 into dotnet:main Dec 5, 2025
105 of 108 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants