Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integer conversions do not detect overflow in corner cases #4245

Closed
vicuna opened this issue Mar 29, 2007 · 2 comments
Closed

Integer conversions do not detect overflow in corner cases #4245

vicuna opened this issue Mar 29, 2007 · 2 comments
Assignees

Comments

@vicuna
Copy link

vicuna commented Mar 29, 2007

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.

@vicuna
Copy link
Author

vicuna commented Mar 29, 2007

Comment author: @oandrieu

The corner case is obviously not handled correctly.

actually, that's on purpose, cf. Xavier's comments in bug #4210

@vicuna
Copy link
Author

vicuna commented Jul 15, 2009

Comment author: @xavierleroy

See comments on #4210

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants