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

Wrong place for variable declaration #2033

Closed
Nordlicht123 opened this issue Jun 12, 2020 · 1 comment
Closed

Wrong place for variable declaration #2033

Nordlicht123 opened this issue Jun 12, 2020 · 1 comment

Comments

@Nordlicht123
Copy link

Hi,
thank you for this great tool.

I've a problem with wrong variable declaration In the attached file.
The first part in the file is the IL code with C#, the second part is the ILAst and at the end is the C# Code of the faulty function.

In the C# part I've comment the faulty declaration, calculation and usage of the variable d, num5 and d2. I illustrated the problem in the simplified code inserted below. In the ILAst part the variable d, num5 and d2 are declared and inititalized with "0" outside the foreach loop. In the wrong C# code the calculation is done and will be cleared in the following loop. In the following "else if" block the variable d, num5 and d2 are always "0", the correct calculates values from the previous loop are lost.

I hope my description was helpful.

Yours
Stefan

foreach (DataPoint point in series.Points)
{
...
  decimal d = default(decimal);			<--- Clear d (wrong)
  decimal num5 = default(decimal);		<--- Clear num5 (wrong)
  decimal d2 = default(decimal);		<--- Clear d2 (wrong)
   if (num2 + GlobalForm.ChartStartIndex == num)
   {
	...
	d = new decimal((absolutePoint2.Y - absolutePoint.Y) / (absolutePoint2.X - absolutePoint.X));	<--- Calculation of d, not use in this block anymore
	num5 = new decimal((absolutePoint4.Y - absolutePoint3.Y) / (absolutePoint4.X - absolutePoint3.X));	<--- Calculation of num5, not use in this block anymore
	d2 = new decimal((absolutePoint2.X - absolutePoint.X) / (float)(num4 - num3));				<--- Calculation of d2, not use in this block anymore
	ShowTarget(e, series, i, num2 + 1);
   }
   else if (num2 + GlobalForm.ChartStartIndex > num)
   {
      decimal num6 = new decimal(Convert.ToSingle(decimal.Multiply(decimal.Multiply(d, new decimal(num2 + 1 - num3)), d2)) + absolutePoint.Y);    <--- Use of d, d2 calculate above
      decimal d3 = new decimal(Convert.ToSingle(decimal.Multiply(decimal.Multiply(num5, new decimal(num2 + 1 - num3)), d2)) + absolutePoint3.Y);  <--- Use of num5, d2 calculate above
...
  }
}

Wrong variable declaration.txt

@siegfriedpammer
Copy link
Member

Would it be possible for you to provide the binary? Having the binary would make debugging this a lot easier. If you want to provide it through a private channel, you can use my email address [email protected]

Thank you very much!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants