[libcxx-commits] [libcxx] r374684 - [libc++][test] Silence MSVC warning in std::optional test

Casey Carter via libcxx-commits libcxx-commits at lists.llvm.org
Sat Oct 12 12:01:47 PDT 2019


Author: caseycarter
Date: Sat Oct 12 12:01:46 2019
New Revision: 374684

URL: http://llvm.org/viewvc/llvm-project?rev=374684&view=rev
Log:
[libc++][test] Silence MSVC warning in std::optional test

`make_optional<string>(4, 'X')` passes `4` (an `int`) as the first argument to `string`'s `(size_t, charT)` constructor, triggering a signed/unsigned mismatch warning when compiling with MSVC at `/W4`. The incredibly simple fix is to instead use an unsigned literal (`4u`).

Modified:
    libcxx/trunk/test/std/utilities/optional/optional.specalg/make_optional_explicit.pass.cpp

Modified: libcxx/trunk/test/std/utilities/optional/optional.specalg/make_optional_explicit.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/optional/optional.specalg/make_optional_explicit.pass.cpp?rev=374684&r1=374683&r2=374684&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/optional/optional.specalg/make_optional_explicit.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/optional/optional.specalg/make_optional_explicit.pass.cpp Sat Oct 12 12:01:46 2019
@@ -40,7 +40,7 @@ int main(int, char**)
         assert(s == nullptr);
     }
     {
-        auto opt = make_optional<std::string>(4, 'X');
+        auto opt = make_optional<std::string>(4u, 'X');
         assert(*opt == "XXXX");
     }
 




More information about the libcxx-commits mailing list