Skip to content

Out of range literals #1

@dmjio

Description

@dmjio

@atomb,

cc @travitch

When attempting to build, I noticed this warning in cabal,

src/Dalvik/Instruction.hs:642:46: Warning:
    Literal 240 is out of the Int8 range -128..127

src/Dalvik/Instruction.hs:646:50: Warning:
    Literal 4294901760 is out of the Int32 range -2147483648..2147483647

src/Dalvik/Instruction.hs:651:42: Warning:
    Literal 18446744069414584320 is out of the Int64 range -9223372036854775808..9223372036854775807

regarding these lines:

signExt4 :: Word8 -> Int8
signExt4 w = w' .|. (if w' .&. 0x8 /= 0 then 0xF0 {- 240 -} else 0)
  where w' = fromIntegral w

signExt16 :: Word32 -> Int32
signExt16 w = w' .|. (if w' .&. 0x8000 /= 0 then 0xFFFF0000 {-4294901760-} else 0)
  where w' = fromIntegral w

signExt32 :: Int64 -> Int64
signExt32 w =
  w' .|. (if w' .&. 0x80000000 /= 0 then 0xFFFFFFFF00000000 {-18446744069414584320-} else 0)
    where w' = fromIntegral w

Is the intention here to make the these literals max bounds?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions