Skip to content

C backend does not generate function pointer conversion #22427

@ruihe774

Description

@ruihe774

Zig Version

0.14.0-dev.2587+f57a7458b

Steps to Reproduce and Observed Behavior

A minimal example:

fn awd() void {}

pub fn main() void {
    @as(*const fn (u32) void, @ptrCast(&awd))(1);
}

Quoted from the generated non-compilable C code:

static void test_awd__224(void) {
 return;
}

static void test_main__225(void) {
 /* file:2:59 */
 test_awd__224(UINT32_C(1));
 return;
}

See also #22368 (comment)

Expected Behavior

The generated C code includes the function pointer conversion and can be compiled by C compiler.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionNo questions on the issue tracker, please.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions