bugDotGNU Portable.NET - Bugs: bug #10411, String.Compare throws invalid...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #10411: String.Compare throws invalid exception

Submitter:  None
Submitted:  Thu 16 Sep 2004 09:20:30 AM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  Closed

Mon 22 Nov 2004 12:53:41 PM UTC, comment #1: 

Fixed in cvs 11/22/2004.

Klaus Treichel <ktreichel>
Group administrator
Thu 16 Sep 2004 09:20:30 AM UTC, original submission:  

The following code should not throw any exceptions , but throws an exception in pnet.

  String.Compare("01234567890",1, "123",1, 7);

It throws the following exception

Uncaught exception: System.ArgumentOutOfRangeException: String range is out of range
Parameter name: length2
        at System.Globalization.CompareInfo.DefaultCompare(String, Int32, Int32, String, Int32, Int32, CompareOptions) in ./System/Globalization/CompareInfo.cs:234
        at System.Globalization.CompareInfo.Compare(String, Int32, Int32, String, Int32, Int32, CompareOptions) in ./System/Globalization/CompareInfo.cs:170
        at System.String.Compare(String, Int32, String, Int32, Int32) in ./System/String.cs:219
        at XYZ.Main()

It looks as though Compare should be doing a Math.Min(length, strA.Length - indexA) for the length1 and length2 . (But that wouldn't throw the right exceptions anyway).

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #1771:  string.cs added by None (116B - application/octet-stream - simple test case)

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

 

Follow 3 latest changes.

Date Changed by Updated Field Previous Value => Replaced by
2004-11-22 ktreichel StatusNone Fixed
    Open/ClosedOpen Closed
2004-09-16 None Attached File- Added string.cs, #1675

Back to the top

Powered by Savane 3.15-94dd.
Corresponding source code