[libcxx-commits] [libcxx] fe958b1 - [libc++] Quick fix to remove a narrowing conversion from the in_out_result test.

Konstantin Varlamov via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jan 12 01:50:00 PST 2022


Author: Konstantin Varlamov
Date: 2022-01-12T01:49:46-08:00
New Revision: fe958b140ab37acf316f5b98318e75ba2119d5a2

URL: https://github.com/llvm/llvm-project/commit/fe958b140ab37acf316f5b98318e75ba2119d5a2
DIFF: https://github.com/llvm/llvm-project/commit/fe958b140ab37acf316f5b98318e75ba2119d5a2.diff

LOG: [libc++] Quick fix to remove a narrowing conversion from the in_out_result test.

This needs a proper solution in a follow-up. The issue is that the
Standard defines conversions between `in_out_result` classes with
different template types as just `return {in, out};`. Because the
expression uses list initialization, it will fail to compile if the
conversion happens to be narrowing -- which is probably unintended.

Surprisingly, this error wasn't caught by the CI.

Differential Revision: https://reviews.llvm.org/D117089

Added: 
    

Modified: 
    libcxx/test/std/algorithms/algorithms.results/in_out_result.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/test/std/algorithms/algorithms.results/in_out_result.pass.cpp b/libcxx/test/std/algorithms/algorithms.results/in_out_result.pass.cpp
index e7a311c8bf5c4..d66426b0469c2 100644
--- a/libcxx/test/std/algorithms/algorithms.results/in_out_result.pass.cpp
+++ b/libcxx/test/std/algorithms/algorithms.results/in_out_result.pass.cpp
@@ -53,8 +53,9 @@ int main(int, char**) {
   // Conversion, fundamental types.
   {
     std::ranges::in_out_result<int, bool> x = {2, false};
-    std::ranges::in_out_result<double, char> y = x;
-    assert(y.in == 2.0);
+    // FIXME(varconst): try a narrowing conversion.
+    std::ranges::in_out_result<long, char> y = x;
+    assert(y.in == 2);
     assert(y.out == '\0');
   }
 
@@ -138,4 +139,3 @@ int main(int, char**) {
 
   return 0;
 }
-


        


More information about the libcxx-commits mailing list