Skip to content

Transmuting the same trait object with different lifetimes #282

Open
@Darksonn

Description

@Darksonn

Consider the following situation:

  • You have an Box<dyn SomeTrait + 'a>
  • You transmute it to a Box<dyn SomeTrait + 'static>

Is this transmute UB, assuming you actually destroy the box before the end of the lifetime 'a? It is a transmute that I see people do relatively often.

Similarly for &dyn SomeTrait and &mut dyn SomeTrait.

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