[Mono-bugs] [Bug 586664] New: Incorrect values in array after very basic operations

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Mar 9 10:35:31 EST 2010


http://bugzilla.novell.com/show_bug.cgi?id=586664

http://bugzilla.novell.com/show_bug.cgi?id=586664#c0


           Summary: Incorrect values in array after very basic operations
    Classification: Mono
           Product: Mono: Runtime
           Version: 2.4.x
          Platform: 64bit
        OS/Version: Ubuntu
            Status: NEW
          Severity: Critical
          Priority: P5 - None
         Component: JIT
        AssignedTo: lupus at novell.com
        ReportedBy: eiver at eiver.net
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


User-Agent:       Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.8)
Gecko/20100215 Linux Mint/7 (Gloria) Shiretoko/3.5.7

OS: Ubuntu Karmic 64-bit
Mono: Mono JIT compiler version 2.4.2.3 (Debian 2.4.2.3+dfsg-2)
(I also tried version 2.6.1 - had trouble installing it from source, but the
bug seems to exsist there too)

The bug does not exist in Mono: 2.0.1

Example code:

using System;

namespace BugTest
{
    class MainClass
    {
        public static void Main (string[] args)
        {
            double nb = 1.0 / Math.Pow(2, 1);            // nb == 1.0 / 2.0 ==
0.5
            double[] arr = new double[2] { -nb, -nb };    // arr[0] == -0.5,
arr[1] == -0.5

            Console.WriteLine("nb = " + nb);            // ok
            Console.WriteLine("arr[0]  = " + arr[0]);    // ERROR! arr[0]
suddenly equals -2
            Console.WriteLine("arr[1]  = " + arr[1]);    // ok
        }
    }
}

Reproducible: Always

Steps to Reproduce:
1. Just run the code posted in Details
2.
3.
Actual Results:  
The code outputs:
nb = 0.5
arr[0]  = -2
arr[1]  = -0.5


Expected Results:  
The code should output:
nb = 0.5
arr[0]  = -0.5
arr[1]  = -0.5

Only running the code as it is produces this bug. Changing anything makes the
bug disappear.

- run the code with a debugger under Monodevelop and the bug is gone
- Replace "Math.Pow(2, 1)" by "2.0" and the bug is gone
- Replace "double[] arr = new double[2] { -nb, -nb };" by
double[] arr = new double[2];
arr[0] = -nb;
arr[1] = -nb;
and this also gets rid of the bug.

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list