Skip to content

Duration overflows when created with Duration::new(u64::MAX, u32::MAX) #32070

@brson

Description

@brson

Creating Duration::new(u64::MAX, u32::MAX) results in a duration of 3 seconds.

From the documentation, it's not clear what Duration::new is supposed to do on overflow, but right now it silently wraps, whereas its overloaded math operators used explicit checked math.

Playground link.

I thought that compiling this in debug mode would panic because of overflow but it doesn't.

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