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

Submitted by:  None
Submitted on:  Thu 16 Sep 2004 09:20:30 AM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned 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>
Project 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

 

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

 

Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

Follow 3 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Mon 22 Nov 2004 12:53:41 PM UTCktreichelStatusNone=>Fixed
  Open/ClosedOpen=>Closed
Thu 16 Sep 2004 09:20:30 AM UTCNoneAttached File-=>Added string.cs, #1675

Back to the top


Powered by Savane 3.1-cleanup1