Skip to content

Overflow from integer negation expressions #633

@mattheww

Description

@mattheww

§6.5.4:18 (fls_CutpaCFCGHQs) includes:

If the result of the negation expression does not fit within the range of the operand type, then arithmetic overflow occurs.

There is an exception which needs to be documented here: arithmetic overflow doesn't occur in some cases where the operand includes a literal and the value of the expression would fit in the type (eg -128_u8 or -(128_u8)).

See rust-lang/reference#1188 for how this was addressed there.

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