Skip to content

Consider using Int64 throughout the API #53

Open

Description

@kolmodin

We use Int in a lot of places, but Haskell only guarantees 29 bits, and 28 bits of positive integers, or referring up to 256MB.
We should consider using Int64 instead of relying on having >28bits.

Activity

  1. tibbe commented on Apr 16, 2014

    @tibbe
    Contributor

    I think it's safe to assume 32-bits. All Haskell compilers use that. ;)

  2. kolmodin commented on Apr 16, 2014

    @kolmodin
    MemberAuthor

    Wops, Haskell guarantees 30 bits, so 29bits of positive integers or 512MB.
    There are several haskell compilers and interpreters, and I'm not sure all of them use 32bits. In practice though, I think most people use GHC - meaning 32bits. We also only do testing with GHC.

    This request came from Henning Thielemann wishing for skip64.

    To be fair, we already do plenty of assumptions about Int sizes. The binary instance of Int always writes a Int as if it was Int64 but will on a 32bit machine convert that into 32bits when it's decoded.
    https://github.com/kolmodin/binary/blob/master/src/Data/Binary/Class.hs#L181

  3. amigalemming commented on Apr 16, 2014

    @amigalemming

    I do not have a concrete misbehavior of the 'binary' package, but I am concerned in general that some functions use Int and others use Int64. There is always an architecture where conversion between Int and Int32 or Int64 may overflow. Maybe it is even possible to use such overflows for hacker attacks. Thus it is certainly a good idea to use one integer type consistently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions