[PATCH] D32309: [libcxx] [test] Resolve compiler warnings in LCM/GCD tests

Billy Robert O'Neal III via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 8 14:47:57 PDT 2017


BillyONeal 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(
----------------
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.


https://reviews.llvm.org/D32309





More information about the cfe-commits mailing list