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

Marshall Clow via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Feb 5 18:08:58 PST 2019


mclow.lists added a comment.

The title of https://wg21.link/LWG2735 is "`std::abs(short)`, `std::abs(signed char)` and others should return `int` instead of `double` in order to be compatible with C++98 and C"

But that's not what you've implemented. 
In your code `std::abs(short)` returns a `short`, etc.

Also, the tests belong in `test/std`, not `test/libcxx`, because they're testing "standard" behavior, not libc++-specific behavior.



================
Comment at: test/libcxx/numerics/c.math/abs.fail.cpp:20
+    unsigned int ui = -5;
+    std::abs(ui); // unsigned types are not allowed
+    
----------------
You should use the error checking bits of the test suite `// expected-error...` to check that this is generating the error that you want.



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

https://reviews.llvm.org/D57778





More information about the libcxx-commits mailing list