[libcxx-commits] [PATCH] D117089: [libc++] Quick fix to remove a narrowing conversion from the in_out_result test.
Konstantin Varlamov via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jan 11 22:29:20 PST 2022
var-const created this revision.
var-const requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D117089
Files:
libcxx/test/std/algorithms/algorithms.results/in_out_result.pass.cpp
Index: libcxx/test/std/algorithms/algorithms.results/in_out_result.pass.cpp
===================================================================
--- libcxx/test/std/algorithms/algorithms.results/in_out_result.pass.cpp
+++ libcxx/test/std/algorithms/algorithms.results/in_out_result.pass.cpp
@@ -53,8 +53,9 @@
// 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 @@
return 0;
}
-
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117089.399209.patch
Type: text/x-patch
Size: 691 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220112/e8b9afd2/attachment-0001.bin>
More information about the libcxx-commits
mailing list