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

Int64.of_string does not detect overflow from positive to negative ints #3302

Closed
vicuna opened this issue Nov 25, 2004 · 2 comments
Closed

Comments

@vicuna
Copy link

vicuna commented Nov 25, 2004

Original bug ID: 3302
Reporter: administrator
Status: closed (set by @xavierleroy on 2011-05-29T10:20:30Z)
Resolution: fixed
Priority: normal
Severity: feature
Fixed in version: 3.12.0+dev
Category: ~DO NOT USE (was: OCaml general)
Related to: #3582 #4210 #4245
Monitored by: jm

Bug description

Messieurs,

I would have expected Int64.of_string to detect overflow when an
apparently positive string produces a negative integer:

: nr@toller 11359 ; ocaml
Objective Caml version 3.08.1

Int64.of_string "9223372036854775808";;

  • : int64 = -9223372036854775808L

Norman

@vicuna
Copy link
Author

vicuna commented Feb 2, 2005

Comment author: administrator

Proposed behavior for int_of_string would be good. However, integer literals in
source code are read as '-' followed by a positive integer converted with
int_of_string. Hence the latter must not fail on 2^(N-1), otherwise - 2^(N-1)
cannot be represented. One possibility would be to use conversions other than
int_of_string et al in the lexer.

@vicuna
Copy link
Author

vicuna commented Aug 28, 2009

Comment author: @xavierleroy

Fixed in CVS trunk, will be in 3.12.

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

1 participant