Skip to content

translate-c: char always converted to u8, even on platforms where char is signed #9154

Open
@ehaas

Description

@ehaas

The following C code on x86_64-macos-gnu does not call abort; but when run via translate-c it does call abort:

#include <stdlib.h>
int main(void) {
    char c = -1;
    if (c != -1) abort();
}

In transType, .Char_S is translated as u8, but it means 'char' for targets where it's signed

Treating .Char_S as signed will break string literal -> char * implicit casts on those platforms; perhaps the proper thing to do is to special-case char * in transType ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    translate-cC to Zig source translation feature (@cImport)

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions