ty_bare_fn consts have an environment pointer, but their type doesn't. · Issue #5210 · rust-lang/rust (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

@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.