Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0003582OCaml~DO NOT USE (was: OCaml general)public2005-04-06 18:002016-12-07 16:13
Reporteradministrator 
Assigned To 
PrioritynormalSeverityfeatureReproducibilityalways
StatusresolvedResolutionwon't fix 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0003582: (1073741824 = -1073741824) is true !
DescriptionFull_Name: Thomas de Grivel
Version: 3.08.2
OS: debian
Submission from: robinson-2-82-67-155-88.fbx.proxad.net (82.67.155.88)


The integer literal 1073741824 is accepted even if it is outside the range of
representable integers.

In the ocaml 3.08.2 toplevel:

# 1073741824;;
- : int = -1073741824

# 1073741824 = -1073741824;;
- : bool = true


It really should fail just like it's successor :

# 1073741825;;
Integer literal exceeds the range of representable integers of type int

TagsNo tags attached.
Attached Files

- Relationships
related to 0003302closed Int64.of_string does not detect overflow from positive to negative ints 
related to 0004210closedxleroy little bug in int_of_string 

-  Notes
(0000254)
administrator (administrator)
2005-04-17 11:09

See PR#3302. Obvious fix causes problems with the way integer literals are
parsed.
(0010027)
dsheets (reporter)
2013-07-30 23:30

Should be closed by PR#4210?

xleroy says < http://caml.inria.fr/mantis/view.php?id=4210#c5024 [^] > that the lexer still gives erroneous results but it is not clear why this double negation trick is necessary.
(0010302)
doligez (administrator)
2013-09-03 13:36

As of 4.00.1, the behaviour is still there, and it's unlikely to ever be changed.
(0016718)
shinwell (developer)
2016-12-07 15:07

I checked this and the answer is now false.
(0016719)
shinwell (developer)
2016-12-07 15:11

Actually, no, this isn't entirely fixed: 1073741824 is still accepted as a literal, even if the comparison given by the original author of this issue now does give the right answer.
(0016721)
xleroy (administrator)
2016-12-07 15:32

@shinwell: you're testing on a 64-bit machine while the original example is for a 32-bit machine, so you're just missing the issue.

It is still the case that the decimal integer literal corresponding to max_int+1 parses without error and results in min_int.
(0016722)
doligez (administrator)
2016-12-07 16:13

In order to test on 64-bit machines, you need to compare 4611686018427387904 and -4611686018427387904.

- Issue History
Date Modified Username Field Change
2005-11-18 10:13 administrator New Issue
2008-01-22 17:04 doligez Relationship added related to 0003302
2013-07-30 23:30 dsheets Note Added: 0010027
2013-09-03 13:33 doligez Relationship added related to 0004210
2013-09-03 13:36 doligez Note Added: 0010302
2016-12-07 15:07 shinwell Note Added: 0016718
2016-12-07 15:07 shinwell Status acknowledged => resolved
2016-12-07 15:07 shinwell Resolution open => fixed
2016-12-07 15:07 shinwell Assigned To => shinwell
2016-12-07 15:11 shinwell Note Added: 0016719
2016-12-07 15:11 shinwell Assigned To shinwell =>
2016-12-07 15:11 shinwell Status resolved => confirmed
2016-12-07 15:32 xleroy Note Added: 0016721
2016-12-07 16:13 doligez Note Added: 0016722
2016-12-07 16:13 doligez Status confirmed => resolved
2016-12-07 16:13 doligez Resolution fixed => won't fix
2016-12-07 16:13 doligez Description Updated View Revisions
2017-02-23 16:36 doligez Category OCaml general => -OCaml general
2017-03-03 17:55 doligez Category -OCaml general => -(deprecated) general
2017-03-03 18:01 doligez Category -(deprecated) general => ~deprecated (was: OCaml general)
2017-03-06 17:04 doligez Category ~deprecated (was: OCaml general) => ~DO NOT USE (was: OCaml general)


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker