[libcxx-commits] [PATCH] D114244: [libc++] Avoid potential truncation warnings in std::abs test

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Nov 19 07:00:07 PST 2021


ldionne created this revision.
ldionne requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

One some platforms, -Wimplicit-int-conversion is enabled by default,
which can lead to additional warnings being triggered in this test.
Since we're only trying to test errors related to calling abs(), the
assignment is superfluous.

As a fly-by fix, correct one instance of ::abs to std::abs.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114244

Files:
  libcxx/test/std/numerics/c.math/abs.fail.cpp


Index: libcxx/test/std/numerics/c.math/abs.fail.cpp
===================================================================
--- libcxx/test/std/numerics/c.math/abs.fail.cpp
+++ libcxx/test/std/numerics/c.math/abs.fail.cpp
@@ -13,19 +13,19 @@
 int main(int, char**)
 {
     unsigned int ui = -5;
-    ui = std::abs(ui); // expected-error {{call to 'abs' is ambiguous}}
+    (void)std::abs(ui); // expected-error {{call to 'abs' is ambiguous}}
 
     unsigned char uc = -5;
-    uc = std::abs(uc); // expected-warning {{taking the absolute value of unsigned type 'unsigned char' has no effect}}
+    (void)std::abs(uc); // expected-warning {{taking the absolute value of unsigned type 'unsigned char' has no effect}}
 
     unsigned short us = -5;
-    us = std::abs(us); // expected-warning {{taking the absolute value of unsigned type 'unsigned short' has no effect}}
+    (void)std::abs(us); // expected-warning {{taking the absolute value of unsigned type 'unsigned short' has no effect}}
 
     unsigned long ul = -5;
-    ul = std::abs(ul); // expected-error {{call to 'abs' is ambiguous}}
+    (void)std::abs(ul); // expected-error {{call to 'abs' is ambiguous}}
 
     unsigned long long ull = -5;
-    ull = ::abs(ull); // expected-error {{call to 'abs' is ambiguous}}
+    (void)std::abs(ull); // expected-error {{call to 'abs' is ambiguous}}
 
     return 0;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114244.388493.patch
Type: text/x-patch
Size: 1367 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20211119/ec20137e/attachment.bin>


More information about the libcxx-commits mailing list