Skip to content

Storable.alignment (0 :: Word64) gives incorrect result on 32 bit systems

Summary

Storable.alignment (0 :: Word64) gives incorrect result on 32 bit systems

Steps to reproduce

On a 32 bit system:

GHCi, version 9.2.5: https://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /home/erikd/.ghci
λ > import Data.Word
Prelude Data.Word
λ > import Foreign.Storable
Prelude Data.Word Foreign.Storable
λ > sizeOf (0 :: Word64)
8
Prelude Data.Word Foreign.Storable
λ > alignment (0 :: Word64)
4

The alignment value being smaller than the sizeOf is probably always a bug.

Expected behavior

On a 64 bit system:

GHCi, version 9.2.5: https://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /home/erikd/.ghci
λ > import Data.Word
Prelude Data.Word
λ > import Foreign.Storable
Prelude Data.Word Foreign.Storable
λ > sizeOf (0 :: Word64)
8
Prelude Data.Word Foreign.Storable
λ > alignment (0 :: Word64)
8

Environment

  • GHC version used: 9.2.5

Optional:

  • Operating System: Linux
  • System Architecture: x86_64 and emulated x86 as the 32 bit system
Edited by Erik de Castro Lopo
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information