Skip to content
This repository was archived by the owner on Jan 24, 2022. It is now read-only.
This repository was archived by the owner on Jan 24, 2022. It is now read-only.

#[pre_init] safety is questionable #230

@jonas-schievink

Description

@jonas-schievink

#[pre_init] requires that the function it is applied to is unsafe, since the function is run before .bss/.data is initialized. However, unsafe fn means that the function is unsafe to call, while a #[pre_init] function is actually unsafe to implement (it might additionally be unsafe to call from any other place than the pre-init hook). One way to express this would be to require the function body to contain only an unsafe {} block (similar to how #[naked] functions work).

Another issue is that it is neither clear nor documented what happens to promoted statics, which are easy to accidentally create. Presumably, accessing them and creating them is immediate UB.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions