Skip to content

std.mem.writeIntNative accepts more integer types than std.mem.readIntNative #17683

@cbilz

Description

@cbilz

Zig Version

0.12.0-dev.1200+5f92b070b

Steps to Reproduce and Observed Behavior

std.mem.readIntNative only accepts integer bit widths divisible by 8, while std.mem.writeIntNative accepts all integer bit widths.

This means that some integer types are writeable but not readable using these functions.

I'm unsure whether arbitrary bit widths should be supported.

More context:

  • The related functions writeIntForeign, writeIntLittle, writeIntBig and their read counterparts can't reasonably support arbitrary bit widths because they use @byteSwap.
  • read/write(Var)PackedInt provide more general functionality.

Expected Behavior

The two functions to accept the same integer types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    standard libraryThis issue involves writing Zig code for the standard library.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions