[libcxx-commits] [PATCH] D93456: [libcxx] Avoid overflows in the windows __libcpp_steady_clock_now()
Adrian McCarthy via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Dec 17 09:08:48 PST 2020
amccarth accepted this revision.
amccarth added a comment.
This looks correct and straightforward, so LGTM.
There's probably a "clever" solution involving finding the greatest common divisor (once) of `nano::den` and `freq.QuadPart`. That would depend on there being a significant common divisor (which I assume is probably true, but not guaranteed). I think the straightforward solution in this patch is better.
Comment at: libcxx/test/std/utilities/time/time.clock/time.clock.steady/now.pass.cpp:28
assert(t2 >= t1);
+ assert(t2 > std::chrono::time_point<C>());
I don't know what the libcxx style guidelines say, but my inclination would be to add a comment explaining this assertion. Since the original bug would only occasionally be caught by this assertion, somebody who encounters it might need a hint to look for arithmetic overflows.
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
More information about the libcxx-commits