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

Unnecessary uint casts/conversions for certain bitwise operations in ILSpy 6.2p2 #2166

Closed
lbmaian opened this issue Sep 19, 2020 · 0 comments
Labels
Bug Decompiler The decompiler engine itself

Comments

@lbmaian
Copy link

lbmaian commented Sep 19, 2020

This seems to be a regression from the fixes for #1796

I've found two cases where uint casts and constant conversions to unsigned are unnecessary. Possibly also applies to other unsigned integral types.

Input code

Decompiler settings reset to default.

Source as entered in LINQPad 5:

int Foo(int x)
{
	if ((x & 0x10) != 0)
		return 1;
	return 0;
}

byte Bar(int x)
{
	return (byte)(x & 0x10);
}

Assembly: query_jsdiku.zip

Erroneous output

Actual output:

private int Foo(int x)
{
	if (((uint)x & 0x10u) != 0)
	{
		return 1;
	}
	return 0;
}

private byte Bar(int x)
{
	return (byte)((uint)x & 0x10u);
}

Expected output (as decompiled by ILSpy 6.1):

private int Foo(int x)
{
	if ((x & 0x10) != 0)
	{
		return 1;
	}
	return 0;
}

private byte Bar(int x)
{
	return (byte)(x & 0x10);
}

Details

  • Product in use: ILSpy
  • Version in use: 6.2.0.6118-preview2
@lbmaian lbmaian added Bug Decompiler The decompiler engine itself labels Sep 19, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 18, 2025
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

No branches or pull requests

1 participant