Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

decompilation of large uint constants cast to decimal is incorrect #2949

Closed
DS-AdamMilazzo opened this issue Apr 5, 2023 · 0 comments · Fixed by #2953
Closed

decompilation of large uint constants cast to decimal is incorrect #2949

DS-AdamMilazzo opened this issue Apr 5, 2023 · 0 comments · Fixed by #2953
Labels
Bug Decompiler The decompiler engine itself

Comments

@DS-AdamMilazzo
Copy link

DS-AdamMilazzo commented Apr 5, 2023

Steps to reproduce

  1. Compile (decimal)uint.MaxValue under .NET Core 6 or later (or otherwise produce the following IL)
  2. This should result in IL containing ldc.i4.m1; newobj System.Decimal::.ctor(uint32)
  3. This incorrectly decompiles to -1m instead of something like 4294967295m

Note, this affects any uint constant > int.MaxValue. E.g.

  1. Compile (decimal)(uint.MaxValue-1000)
  2. This results in ldc.i4 -1001; newobj System.Decimal::.ctor(uint32)
  3. This incorrectly decompiles to -1001m

I haven't tested the behavior of large ulong constants cast to decimal, but it'd be worth looking at.

Screenshot

image

Details

  • Product in use: ILSpy
  • Version in use: 7.2.1.6856
@DS-AdamMilazzo DS-AdamMilazzo changed the title decompilation of (decimal)uint.MaxValue is incorrect decompilation of large uint values cast to decimal is incorrect Apr 5, 2023
@DS-AdamMilazzo DS-AdamMilazzo changed the title decompilation of large uint values cast to decimal is incorrect decompilation of large uint constants cast to decimal is incorrect Apr 5, 2023
@christophwille christophwille added the Decompiler The decompiler engine itself label Apr 7, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Decompiler The decompiler engine itself
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants