8000 Breakdown the "seconds + femtoseconds => time_point" overflow issue. by devbww · Pull Request #200 · google/cctz · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Breakdown the "seconds + femtoseconds => time_point" overflow issue. #200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 8, 2021

Conversation

devbww
Copy link
Contributor
@devbww devbww commented Oct 7, 2021

When cctz::parse() produces seconds+femtoseconds values that cannot
be represented in the output time_point<D> it should return false.
Here we add overloads of join_seconds() that break the overflow issue
down into four cases, three of which are implemented and have test cases.

The fourth overload (for 1/N duration ratios) is yet to be implemented,
so its test cases are currently commented out, but they provide a guide
to what remains to be done. See #199.

Also, clarify that the ToUnixSeconds() implementation requires that
the std::chrono::system_clock uses the Unix epoch in order to avoid
arithmetic overflow.


This change is Reviewable

When `cctz::parse()` produces seconds+femtoseconds values that cannot
be represented in the output `time_point<D>` it should return `false`.
Here we add overloads of `join_seconds()` that break the overflow issue
down into four cases, three of which are implemented and have test cases.

The fourth overload (for 1/N duration ratios) is yet to be implemented,
so its test cases are currently commented out, but they provide a guide
to what remains to be done.  See google#199.

Also, clarify that the `ToUnixSeconds()` implementation requires that
the `std::chrono::system_clock` uses the Unix epoch in order to avoid
arithmetic overflow.
@google-cla google-cla bot added the cla: yes label Oct 7, 2021
@devbww devbww marked this pull request as ready for review October 8, 2021 00:48
@devbww devbww requested a review from devjgm October 8, 2021 01:11
Copy link
Contributor
@devjgm devjgm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@devbww devbww merged commit 9af727a into google:master Oct 8, 2021
@devbww devbww deleted the parse-overflow branch October 8, 2021 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these iss 36BD ues.

2 participants
0