Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0004689OCamlOCaml generalpublic2009-01-09 16:002012-08-02 19:25
Reporterllb 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionsuspended 
PlatformOSOS Version
Product Version3.11.0+beta 
Target VersionFixed in Version 
Summary0004689: Error not raised with max_int+1 integer literal
Description# max_int;;
- : int = 1073741823

# 1073741824;;
- : int = -1073741824

# 1073741825;;
Characters 0-10:
  1073741825;;
  ^^^^^^^^^^
Error: Integer literal exceeds the range of representable integers of type int


The integer literal 1073741824 should rise an error, since it's greater than max_int. It currently returns an erroneous value.
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0004811)
llb (reporter)
2009-01-09 16:03

Oops, sorry, bad title.
Should be "Error not raised with max_int+1 integer literal", or something like that.
(0004815)
doligez (administrator)
2009-01-14 14:06

Note: for technical reasons, this is unlikely to be fixed in the near future.

(0007875)
xleroy (administrator)
2012-08-02 19:25

Let me document the "technical reasons".

1- Because "f-1" should not be parsed as "f(-1)", "-1073741824" is, lexically, the unary minus operator applied to "1073741824". So, we need to be able to represent "1073741824" (the opposite of min_int) in lexer tokens.

2- Still assuming a 32-bit platform, we really want to be able to write
"x land 0x4000_0000" (or similar bit-masking operations) and not be forced to write "x land (-0x4000_0000)".

The problem reported could possibly be solved by keeping integer literals as strings during lexing and parsing, pushing their resolution into integers deeper in the compiler. But that's a lot of changes for a minor benefit. I'm suspending this PR until someone comes up with a better idea.
  

- Issue History
Date Modified Username Field Change
2009-01-09 16:00 llb New Issue
2009-01-09 16:03 llb Note Added: 0004811
2009-01-14 14:05 doligez Summary Error => Error not raised with max_int+1 integer literal
2009-01-14 14:06 doligez Note Added: 0004815
2009-01-14 14:06 doligez Status new => acknowledged
2012-07-11 14:59 doligez Target Version => 4.01.0+dev
2012-07-31 13:36 doligez Target Version 4.01.0+dev => 4.00.1+dev
2012-08-02 19:25 xleroy Note Added: 0007875
2012-08-02 19:25 xleroy Status acknowledged => resolved
2012-08-02 19:25 xleroy Resolution open => suspended
2012-08-02 19:25 xleroy Target Version 4.00.1+dev =>


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker