Skip to content

transpile: Broken output for static string pointers initialised with compound literal #1410

@Rua

Description

@Rua

As mentioned in #1407, the following code is transpiled to broken Rust code in a static/global context:

char *static_char_ptr = (char[]) { "hello" };
pub static mut static_char_ptr: *mut core::ffi::c_char = unsafe {
    [
        ::core::mem::transmute::<[u8; 6], [core::ffi::c_char; 6]>(*b"hello\0"),
        0,
        0,
        0,
        0,
        0,
    ]
    .as_ptr() as *mut _
};

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