Skip to content
This repository was archived by the owner on Feb 7, 2021. It is now read-only.
This repository was archived by the owner on Feb 7, 2021. It is now read-only.

Undefined Behavior when T is zero-sized #5

@TyPR124

Description

@TyPR124

stowaway/src/lib.rs

Lines 212 to 217 in fb1d8d1

pub fn new(value: T) -> Self {
let storage = match Self::size_class() {
SizeClass::Zero => {
mem::forget(value);
ptr::null_mut()
}

SizeClass::Zero => unsafe { ptr::read(storage) },

Per ptr::read: Note that even if T has size 0, the pointer must be non-NULL and properly aligned.

https://doc.rust-lang.org/std/ptr/fn.read.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions