Skip to content

prevent size overflows in the type system #17913

Closed
@thestinger

Description

@thestinger

Type size calculations inside the compiler can overflow, resulting in memory unsafety. Types without a valid mem::size_of should be forbidden to prevent unsoundness. Types that are valid today would become invalid and this would interfere with an attempt to support integer type parameters. I think it's a serious backwards compatibility issue since the interaction with generics is very bad.

std::mem::size_of::<[[u8, ..!0u], ..!0u]>() returns 1, since !0u * !0u wraps to 1. The same thing can be done with other aggregate types like structs / tuples and an overflow could also occur from the tag added in an enum.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-type-systemArea: Type systemI-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions