Skip to content

implicit int overflow slightly beyond 32-bit max #6025

Closed
@Agapurnis

Description

@Agapurnis

When going one above the max positive 32-bit integer, it overflows and becomes negative.

Example

Verbose for clarity; separators and type annotations don't change the outcome.

// Correct; this is a safe value.
let value: int = 2_147_483_647

// Incorrect; this gets transpiled to `-2_147_483_648`. Ideally, this should warn or error.
let value: int = 2_147_483_648

// Correct; this errors for not being a valid 32-bit integer.
let value: int = 2_147_483_649

Search Keywords

int, int32, sign, flip, 32-bit, integer limit, safe integer, integer overflow

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