Skip to content

Signedness of c_char differs on ARMv7 vs. x86_64 #48633

Closed
@hsivonen

Description

@hsivonen

On Linux on ARMv7, c_char is u8. On Linux on x86_64, c_char is `i8. See the XPCOM bug that caused me to find out.

Does importing this design flaw of the C language into Rust solve any real problem, considering that Rust runs only on two's-complement systems and the FFI ABI for u8 and i8 is the same?

If not, I suggest making the signedness of c_char in Rust the same across platforms. Ideally, it would be u8, but since x86_64 is the most common platform that developers use and it's i8 there, it might not be feasible to use u8 without breaking existing code. (Theoretically, changing the signedness for ARMv7 is a breaking change, but it practice, it isn't a breaking change for code that already compiles on x86_64 also, which is most crates except maybe some embedded specialty crates.)

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