Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006299OCamlOCaml runtime systempublic2014-01-20 15:492014-05-03 08:45
Reporterjrrk100 
Assigned To 
PrioritynormalSeveritymajorReproducibilityalways
StatusresolvedResolutionno change required 
Platformamd64OSOSXOS Version10.9.1
Product Version 
Target VersionFixed in Version 
Summary0006299: Ocaml 4.01.0 lsr function in OCaml only uses bottom 7 bits of shift value
DescriptionWhen using x lsr y where y is a large number (> 63), the answer should always be zero, however if y reaches 128 the actual shift goes back to zero.
Steps To Reproduce$ ocaml
        OCaml version 4.01.0

# 1024 lsr 9;;
- : int = 2
# 1 lsr 128;;
- : int = 1
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0010818)
dbuenzli (reporter)
2014-01-20 16:14

The result is unspecified if y > platform width (see the docs) .
(0011340)
xleroy (administrator)
2014-05-03 08:45

This is documented clearly in the users's manual.

"n lsr m shifts n to the right by m bits. This is a logical shift: zeroes are inserted regardless of the sign of n. The result is unspecified if m < 0 or m >= bitsize."

Note that different processors behave differently if m < 0 or m >= bitsize. For example, x86-64 takes m modulo 64, but ARM-32 takes m modul0 256.

- Issue History
Date Modified Username Field Change
2014-01-20 15:49 jrrk100 New Issue
2014-01-20 16:14 dbuenzli Note Added: 0010818
2014-05-03 08:45 xleroy Note Added: 0011340
2014-05-03 08:45 xleroy Priority high => normal
2014-05-03 08:45 xleroy Status new => resolved
2014-05-03 08:45 xleroy Resolution open => no change required


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker