Skip to content

Checked arithmetic is wrong for Durations smaller than 100ns on Windows #149995

@cvengler

Description

@cvengler

I tried this code:

let system_time: SystemTime = ...;

// Add 1ns.
system_time.checked_add(Duration::new(0, 1)).unwrap();

I expected to see this happen: The unwrap to fail because SystemTime on Windows only has an accuracy of 100ns.

Instead, this happened: The addition "works" by returning some, although the value is unchanged from the original one, meaning an addition of a Duration < 100ns is equivalent of adding Duration::ZERO.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions