[PATCH] D32309: [libcxx] [test] Resolve compiler warnings in LCM/GCD tests
Eric Fiselier via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon May 8 14:49:00 PDT 2017
EricWF added inline comments.
================
Comment at: test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp:42
+constexpr bool test0(int in1, int in2, int out)
{
+ static_assert(std::is_same<Output, decltype(
----------------
BillyONeal wrote:
> EricWF wrote:
> > Nit but this seems much cleaner and more readable without the casts.
> >
> > ```
> > auto value1 = static_cast<Input1>(in1);
> > auto value2 = static_cast<Input2>(in2);
> > static_assert(std::is_same_v<Output, decltype(std::gcd(value1, value2))>, "");
> > static_assert(std::is_same_v<Output, decltype(std::gcd(value2, value1))>, "");
> > assert(static_cast<Output>(out) == std::gcd(value1, value2));
> > return true;
> > ```
> >
> > Also just use `assert` instead of `std::abort()`
> I was under the impression the abort dance was because assert isn't constexpr.
`assert` is constexpr for the exact same reason the `abort` dance was constexpr.
And I think somebody else was under the same misapprehension when they wrote this test.
https://reviews.llvm.org/D32309
More information about the cfe-commits
mailing list