Skip to content

Shouldn't modulus with a readonly integer not be reduced? #116496

Answered by EgorBo
Genbox asked this question in General
Discussion options

You must be logged in to vote

it can be assumed the value is constant, no?

No, it cannot, it may be changed with reflection and if you can't use const it is implied you have a more complex expression there. There is not much JIT can legally do in this case, only static readonly is allowed to be constant-folded.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@Genbox
Comment options

@EgorBo
Comment options

EgorBo Jun 10, 2025
Collaborator

Answer selected by Genbox
@Genbox
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants