[libcxx-commits] [PATCH] D93456: [libcxx] Avoid overflows in the windows __libcpp_steady_clock_now()

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jan 12 07:42:55 PST 2021

ldionne accepted this revision.
ldionne added a comment.
This revision is now accepted and ready to land.

LGTM with or without the test comment.

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>());
amccarth wrote:
> 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.
I think a short comment doesn't hurt. Ideally something that isn't strictly related to the bug, like `// make sure t2 didn't wrap around` or something along those lines.

  rG LLVM Github Monorepo



More information about the libcxx-commits mailing list