[Mono-bugs] [Bug 389138] New: C# compiler code fails when running under .NET Framework

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sun May 11 04:53:02 EDT 2008


https://bugzilla.novell.com/show_bug.cgi?id=389138


           Summary: C# compiler code fails when running under .NET Framework
           Product: Mono: Compilers
           Version: 1.9.0
          Platform: x86
        OS/Version: Windows Vista
            Status: NEW
          Severity: Major
          Priority: P5 - None
         Component: C#
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: mihailik at gmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: Other


support.cs, line 385

CharArrayHashtable.GetHash(object key)

throws an OverflowException when called from Tokenizer.InitTokens method with
parameters "abstract", Token.ABSTRACT (cs-tokenizer.cs line 303).

I am using the project **gmcs.csproj** to build the Mono C# compiler.


The cause of failure is overflow when calculating the hash. The simplest way to
fix is to add 'unchecked' keyword to line 385 of support.cs:

                protected override int GetHash (Object key)
                {
                        char[] arr = (char[])key;
                        int h = 0;

                        for (int i = 0; i < len; ++i)
                                h = unchecked((h << 5) - h + arr [i]);

                        return h;
                }


I think the difference between Microsoft's .NET and Mono here is the defaulting
to unchecked in Mono. Nevertheless, for a compatibility it should default to
same. But for a quick fix, explicit 'unchecked' keyword can be used to satisfy
both worlds.


-- 
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