Skip to content

Integer conversions do not detect overflow in corner cases #4245

@vicuna

Description

@vicuna

Original bug ID: 4245
Reporter: @mmottl
Assigned to: @xavierleroy
Status: closed (set by @xavierleroy on 2011-05-29T10:14:02Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 3.09.3
Fixed in version: 3.12.0+dev
Category: ~DO NOT USE (was: OCaml general)
Duplicate of: #4210
Related to: #3302
Monitored by: yminsky @mmottl

Bug description

This should not be accepted:

Int32.of_string "2147483648";;

  • : int32 = -2147483648l

This is correctly rejected (first number + 1):

Int32.of_string "2147483649";;

Exception: Failure "int_of_string".

And this is correctly accepted (first number - 1):

Int32.of_string "2147483647";;

  • : int32 = 2147483647l

The corner case is obviously not handled correctly.

The same problem happens with the other integer conversions: Int64.of_string, Nativeint.of_string, and even int_of_string.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions