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

(1073741824 = -1073741824) is true ! #3582

Closed
vicuna opened this issue Apr 6, 2005 · 7 comments
Closed

(1073741824 = -1073741824) is true ! #3582

vicuna opened this issue Apr 6, 2005 · 7 comments

Comments

@vicuna
Copy link

vicuna commented Apr 6, 2005

Original bug ID: 3582
Reporter: administrator
Status: resolved (set by @damiendoligez on 2016-12-07T15:13:36Z)
Resolution: won't fix
Priority: normal
Severity: feature
Category: ~DO NOT USE (was: OCaml general)
Related to: #3302 #4210
Monitored by: dsheets

Bug description

Full_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

@vicuna
Copy link
Author

vicuna commented Apr 17, 2005

Comment author: administrator

See #3302. Obvious fix causes problems with the way integer literals are
parsed.

@vicuna
Copy link
Author

vicuna commented Jul 30, 2013

Comment author: dsheets

Should be closed by #4210?

xleroy says < #4210#c5024 > that the lexer still gives erroneous results but it is not clear why this double negation trick is necessary.

@vicuna
Copy link
Author

vicuna commented Sep 3, 2013

Comment author: @damiendoligez

As of 4.00.1, the behaviour is still there, and it's unlikely to ever be changed.

@vicuna
Copy link
Author

vicuna commented Dec 7, 2016

Comment author: @mshinwell

I checked this and the answer is now false.

@vicuna
Copy link
Author

vicuna commented Dec 7, 2016

Comment author: @mshinwell

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.

@vicuna
Copy link
Author

vicuna commented Dec 7, 2016

Comment author: @xavierleroy

@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.

@vicuna
Copy link
Author

vicuna commented Dec 7, 2016

Comment author: @damiendoligez

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

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