Skip to content

size_t should be defined as uint #11447

Closed
@nmsmith

Description

@nmsmith

The C-standard definition of size_t states that it must be able to represent the size of any object in bytes. It therefore makes sense for size_t to be defined as uint, to make it equal to the pointer size. Currently (as an example) it's defined as u32 on x86 and u64 on x86-64, but this poses problems with the malloc family of functions in std::libc::funcs::c95::stdlib that accept a size_t, since it is currently invalid to pass them a uint without casting. It makes the most sense to specify the size of a memory allocation with a type of size equal to that of a pointer, so you shouldn't need to do a cast to pass these functions values.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-cleanupCategory: PRs that clean code up or issues documenting cleanup.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions