[Mono-bugs] [Bug 331525] New: Int32.TryParse fails to recognize overflows
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Fri Oct 5 22:14:49 EDT 2007
https://bugzilla.novell.com/show_bug.cgi?id=331525
Summary: Int32.TryParse fails to recognize overflows
Product: Mono: Class Libraries
Version: 1.2
Platform: i686
OS/Version: Linux
Status: NEW
Severity: Normal
Priority: P5 - None
Component: System
AssignedTo: mono-bugs at ximian.com
ReportedBy: leonardo+novell at diptongonante.com
QAContact: mono-bugs at ximian.com
Found By: ---
Since r82261 in the mcs repository[1], Int32.TryParse incorrectly parses a
number below Int32.MinValue and returns true. See attached test case.
The problem is that the logic implemented in Int32.cs by Miguel in that commit,
although clever, is not guaranteed to behave as expected (i.e. a positive
integer is not always going to become a negative number after overflowing, or
viceversa). When detecting integer overflows in multiplications we're stuck
with having to cast to a larger type (C#'s long in this case) and then make the
check. Not as optimal, but still about 5 times faster than try+catch in my
machine.
Attached is also a patch that includes a possible fix, and adds a few more unit
tests to cover this scenario, and some other cases for the TryParse method
involving hexadecimal numbers.
Thanks.
[1] As a side note, this bug is present in mono 1.2.5
--
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