diff options
author | Stefan Schulze Frielinghaus <stefansf@linux.ibm.com> | 2020-07-05 18:42:02 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-07-09 09:49:22 -0400 |
commit | b7de4b960a1024adcd0bded6bd320a90979d7ab8 (patch) | |
tree | d680700fb7403491e122997cce09b2083745b371 /testsuite | |
parent | 3033e0e4940e6ecc43f478f1dcfbd0c3cb1e3ef8 (diff) | |
download | haskell-b7de4b960a1024adcd0bded6bd320a90979d7ab8.tar.gz |
Fix GHCi :print on big-endian platforms
On big-endian platforms executing
import GHC.Exts
data Foo = Foo Float# deriving Show
foo = Foo 42.0#
foo
:print foo
results in an arithmetic overflow exception which is caused by function
index where moveBytes equals
word_size - (r + item_size_b) * 8
Here we have a mixture of units. Both, word_size and item_size_b have
unit bytes whereas r has unit bits. On 64-bit platforms moveBytes
equals then
8 - (0 + 4) * 8
which results in a negative and therefore invalid second parameter for a
shiftL operation.
In order to make things more clear the expression
(word .&. (mask `shiftL` moveBytes)) `shiftR` moveBytes
is equivalent to
(word `shiftR` moveBytes) .&. mask
On big-endian platforms the shift must be a left shift instead of a
right shift. For symmetry reasons not a mask is used but two shifts in
order to zero out bits. Thus the fixed version equals
case endian of
BigEndian -> (word `shiftL` moveBits) `shiftR` zeroOutBits `shiftL` zeroOutBits
LittleEndian -> (word `shiftR` moveBits) `shiftL` zeroOutBits `shiftR` zeroOutBits
Fixes #16548 and #14455
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/tests/ghci.debugger/scripts/all.T | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/testsuite/tests/ghci.debugger/scripts/all.T b/testsuite/tests/ghci.debugger/scripts/all.T index bd92d0ffa8..30e5c4312c 100644 --- a/testsuite/tests/ghci.debugger/scripts/all.T +++ b/testsuite/tests/ghci.debugger/scripts/all.T @@ -28,9 +28,7 @@ test('print020', [extra_files(['../HappyTest.hs']), omit_ways(['ghci-ext'])], ghci_script, ['print020.script']) test('print021', normal, ghci_script, ['print021.script']) -test('print022', - [when(arch('powerpc64'), expect_broken(14455))], - ghci_script, ['print022.script']) +test('print022', normal, ghci_script, ['print022.script']) test('print023', extra_files(['../Test.hs']), ghci_script, ['print023.script']) test('print024', extra_files(['../Test.hs']), ghci_script, ['print024.script']) test('print025', normal, ghci_script, ['print025.script']) |