Skip to content

new in safe contexts #42

Open
Open
@cmazakas

Description

@cmazakas

Assume a simple function like:

box<T> box<T>::make() safe {
  unsafe { return box(new T()); }
}

It's easy to introduce a soundness hole here.

The intent is that this function is sound because even if allocation is unsafe and fails, we simply OOM so we panic and stop execution. We intend that in a safe context only a safe default constructor will be called but new being unsafe necessitates a block where it's easy to silently mask that we now also permit unsafe default constructors, which permits a soundness hole.

Also see: https://godbolt.org/z/xM556saPr

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