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

int_of_string fails on integers starting with a + #6649

vicuna opened this issue Nov 7, 2014 · 3 comments


None yet
1 participant
Copy link

commented Nov 7, 2014

Original bug ID: 6649
Reporter: berke.durak
Status: closed (set by @damiendoligez on 2016-03-21T16:14:02Z)
Resolution: fixed
Priority: low
Severity: minor
Version: 4.01.0
Target version: 4.03.0+dev / +beta1
Fixed in version: 4.03.0+dev / +beta1
Category: standard library
Related to: #5829 #6296
Monitored by: lelf @hcarty

Bug description

The documentation states:

"Raise Failure "int_of_string" if the given string is not a valid representation of an integer, or if the integer represented exceeds the range of integers representable in type int."

But starting an integer with a + is valid:

let x = +1;;

val x : int = 1

Steps to reproduce

int_of_string "+1";;

Exception: Failure "int_of_string".

Additional information

Scanf.sscanf "%d" accepts the +


This comment has been minimized.

Copy link

commented Dec 22, 2014

Comment author: @damiendoligez

Note that #5936 will probably remove the +1 syntax from the language.

Since scanf uses the underlying C implementation, it's less likely to be "fixed" in the same way.


This comment has been minimized.

Copy link

commented Feb 21, 2016

Comment author: chrismamo1

This seems to have bee resolved by #2613 ( #222 )


This comment has been minimized.

Copy link

commented Mar 21, 2016

Comment author: @damiendoligez

Indeed it was resolved by #222. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.