[libcxx-commits] [PATCH] D57778: std::abs should not return double (2735)

Marshall Clow via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sun Feb 10 11:39:42 PST 2019


mclow.lists added inline comments.


================
Comment at: test/std/numerics/c.math/abs.pass.cpp:27
+    
+    ASSERT_SAME_TYPE(decltype(std::abs(neg_val)), R);
+                     
----------------
mclow.lists wrote:
> EricWF wrote:
> > I think this test for the return type can be simplified. We expect `std::abs(T)` to return `U` where `U` is the result of [integral promotion](https://en.cppreference.com/w/cpp/language/implicit_conversion)  on `T`.
> > 
> > Instead of hard-coding the expected type, we can calculate it using the expression `using R = decltype(+pos_value);`
> I suggested that Zoe be explicit here.
In particular, we want to be sure that `std::abs(char)` returns `int`, not `char`, which can be promoted to an `int`.



CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57778/new/

https://reviews.llvm.org/D57778





More information about the libcxx-commits mailing list