[Mono-bugs] [Bug 642975] New: strange const and static problem
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Thu Sep 30 16:30:41 EDT 2010
https://bugzilla.novell.com/show_bug.cgi?id=642975
https://bugzilla.novell.com/show_bug.cgi?id=642975#c0
Summary: strange const and static problem
Classification: Mono
Product: Mono: Runtime
Version: SVN
Platform: 64bit
OS/Version: RHEL 5
Status: NEW
Severity: Normal
Priority: P5 - None
Component: misc
AssignedTo: mono-bugs at lists.ximian.com
ReportedBy: srfcanada at hotmail.com
QAContact: mono-bugs at lists.ximian.com
Found By: ---
Blocker: ---
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.2; WOW64;
Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; MS-RTC LM 8)
the following test fails on mono but passes on windows, but changing the field
"thisIsCausingTheProblem" to a const will make it pass . there seems to be
some strange things happing based on consts and static since changing all the
methods to static seems to make it work also:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Reflection;
using System.Diagnostics;
class monofail4
{
static int Main(string[] args)
{
TestClass1 a1 = new TestClass1();
a1.test1();
Console.WriteLine("Worked!!");
return 0;
}
}
public class TestClass1
{
public void test1()
{
//switching to a constant fixes the problem
double thisIsCausingTheProblem = 5.0;
double[,] m1 = new double[4, 4]
{
{ 1.0, 0.0, 0.0, thisIsCausingTheProblem },
{ 0.0, 1.0, 0.0, thisIsCausingTheProblem },
{ 0.0, 0.0, 1.0, thisIsCausingTheProblem },
{ 0.0, 0.0, 0.0, 1.0 }
};
double[] zeroPoint = new double[3] { 0.0, 0.0, 0.0 };
double[] resultingPoint = new double[3] { 0.0, 0.0, 0.0 };
List<double[]> points = new List<double[]>();
points.Add(new double[3] { 1.0, 0.0, 0.0 });
points.Add(new double[3] { 0.0, 1.0, 0.0 });
points.Add(new double[3] { 0.0, 0.0, 1.0 });
points.Add(new double[3] { 1.0, 0.0, 5.0 });
points.Add(new double[3] { 10.0, 2.0, 3.0 });
points.Add(new double[3] { -1.0, 0.0, 0.0 });
points.Add(new double[3] { 0.0, -1.0, 0.0 });
points.Add(new double[3] { 0.0, 0.0, -1.0 });
points.Add(new double[3] { -1.0, 3.0, -8.0 });
points.Add(new double[3] { 7.0, -8.0, 1.0 });
a2(m1, zeroPoint, resultingPoint);
Console.WriteLine("base value: "+ thisIsCausingTheProblem);
for (int j = 0; j < 3; j++)
{
Console.WriteLine("field1: " + (zeroPoint[j] +
thisIsCausingTheProblem) + " field2: " + resultingPoint[j]);
if ((zeroPoint[j] + thisIsCausingTheProblem) != resultingPoint[j])
throw new Exception("Why dont they equal, it works on ms .net");
}
}
private void a2(double[,] m1, double[] point, double[] resultingPoint)
{
double[] h1 = new double[4] { point[0], point[1], point[2], 1.0 };
double[] h2 = new double[4];
a3(m1, h1, h2);
resultingPoint[0] = h2[0];
resultingPoint[1] = h2[1];
resultingPoint[2] = h2[2];
}
public static void a3(double[,] m1, double[] point, double[]
resultingPoint)
{
// Resetting (initializing) the given resulting point
for (int i = 0; i < 4; i++)
{
resultingPoint[i] = 0.0;
}
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{
resultingPoint[i] += m1[i, j] * point[j];
}
}
}
}
Reproducible: Always
Steps to Reproduce:
1.
2.
3.
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
More information about the mono-bugs
mailing list