Skip to content

Support for mixed sign and size in integer type conversions #1854

@rod-chapman

Description

@rod-chapman

Currently, it appears that Verus does not "know" the semantics of integer type conversions that change the signedness of the argument, or its size (either truncating or expanding the representation.) Verus currently issues a "truncating warning", and nothing can be proven about the result of the conversion.

Rust Reference 8.2.4 says that these conversions are well-defined, so they should be supported. They are also common in cryptographic code.

The work could be broken down into several PR's. For example.

  1. Same size, changing sign (e.g. i32 <-> u32 and so on)
  2. Expanding, same sign (e.g. u8 -> u16, i16 -> i32)
  3. Truncating, same sign (e.g. u16 -> u8, i32 -> i16)
  4. Expanding, mixed signedness (e.g. i8 -> u16, u16 -> i32)
  5. Truncating, mixed signedness (e.h. u32 -> i8, i16 -> u8)

Did I miss any cases?

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