Skip to content

ty_bare_fn consts have an environment pointer, but their type doesn't. #5210

Closed
@jld

Description

@jld
fn f() { }
const fs: &[extern fn()] = &[f, f];
fn main() { for fs.each |&g| { g() } }

The type_of (and sizing_type_of) for that extern fn is just a pointer, but what's getting generated for the constant also has an environment pointer. Because we have to defeat LLVM's type checks to support enums (and we don't have sufficient assertions of our own), we don't catch the mismatch and the second call to f jumps through the first array element's null environment pointer instead.

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