[GHC] #16111: Inconsistent behavior of Data.Bits.shiftL with different optimization levels and -fllvm

GHC ghc-devs at haskell.org
Mon Mar 4 18:51:00 UTC 2019


#16111: Inconsistent behavior of Data.Bits.shiftL with different optimization
levels and -fllvm
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  harpocrates
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.6.3
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Incorrect result  |  Unknown/Multiple
  at runtime                         |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |  https://gitlab.haskell.org/ghc/ghc/merge_requests/113
-------------------------------------+-------------------------------------

Comment (by Ben Gamari <ben@…>):

 In [changeset:"5341edf3635f2875271acc469570481c52000374/ghc" 5341edf/ghc]:
 {{{
 #!CommitTicketReference repository="ghc"
 revision="5341edf3635f2875271acc469570481c52000374"
 Error out of invalid Int/Word bit shifts

 Although the Haddock's for `shiftL` and `shiftR` do require the number
 of bits to be non-negative, we should still check this before calling
 out to primitives (which also have undefined behaviour for negative bit
 shifts).

 If a user _really_ wants to bypass checks that the number of bits is
 sensible, they already have the aptly-named `unsafeShiftL`/`unsafeShiftR`
 at their disposal.

 See #16111.
 }}}

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/16111#comment:13>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list