Skip to content

Specify that int and uint are at least 32 bits on every CPU architecture #14758

Closed
@1fish2

Description

@1fish2

Guaranteeing that int and uint are always at least 32 bits fixes the class of bugs and security holes that worries me most in #9940

Scenario:

  • Programmers use int and uint in library code and sample code explicitly, or by thinking of them as the "default integer types," or via integer type inference. See consider removing the fallback to int for integer inference #6023
  • When reusing that code on a 16-bit embedded processor (e.g. in robotics and IoT devices -- Rust would be very compelling for such applications), it has bugs when int and uint overflow in 16 bits, which is not difficult.

I encountered this problem when programming in C++ on Palm OS. (It's a 16-bit OS even on devices that used a 32-bit ARM to emulate the 68000.)

Of course there are alternate solutions.

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