Skip to content

Feature request: supported unsized globals #1265

Description

@N1ark

Title is misleading, but we need to support globals that may be unsized (whether that means having unsized globals, or having sized globals that can be referenced with metadata, i don't know). This is e.g. an issue for c"strings", where the translation creates unsized variables in the store (notice the _2; Cstr is defined as core::ffi::c_str::CStr { inner: [i8] }

fn test_crate::main::x86_64-unknown-linux-gnu()
{
let _0: (); // return
let _1: &'1 core::ffi::c_str::CStr::x86_64-unknown-linux-gnu; // anonymous local
let _2: core::ffi::c_str::CStr::x86_64-unknown-linux-gnu; // anonymous local
let _3: &'2 core::ffi::c_str::CStr::x86_64-unknown-linux-gnu; // anonymous local
_0 = ()
storage_live(_1)
storage_live(_2)
_2 = core::ffi::c_str::CStr::x86_64-unknown-linux-gnu { inner: const [49i8, 50i8, 51i8, 0i8] }
storage_live(_3)

I'm not aware of other cases where this may happen, but I haven't tried much; maybe a const FOO: &dyn Trait or something like that? Possibly related: #1225

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