[libcxx] r337968 - [libc++] Follow-up to r337960: specify lambda's return type to avoid

Alex Lorenz via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 25 14:50:45 PDT 2018


Author: arphaman
Date: Wed Jul 25 14:50:44 2018
New Revision: 337968

URL: http://llvm.org/viewvc/llvm-project?rev=337968&view=rev
Log:
[libc++] Follow-up to r337960: specify lambda's return type to avoid
-Wc++11-narrowing warning on Darwin

The internal CI produced the following diagnostic:
error: non-constant-expression cannot be narrowed from type 'long long' to '__darwin_suseconds_t' (aka 'int') in initializer list [-Wc++11-narrowing]
  struct ::timeval ConvertedTS[2] = {{TS[0].tv_sec, Convert(TS[0].tv_nsec)},
                                                    ^~~~~~~~~~~~~~~~~~~~~~

Modified:
    libcxx/trunk/src/experimental/filesystem/filesystem_common.h

Modified: libcxx/trunk/src/experimental/filesystem/filesystem_common.h
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/filesystem_common.h?rev=337968&r1=337967&r2=337968&view=diff
==============================================================================
--- libcxx/trunk/src/experimental/filesystem/filesystem_common.h (original)
+++ libcxx/trunk/src/experimental/filesystem/filesystem_common.h Wed Jul 25 14:50:44 2018
@@ -393,7 +393,7 @@ bool set_file_times(const path& p, std::
                     error_code& ec) {
 #if !defined(_LIBCPP_USE_UTIMENSAT)
   using namespace chrono;
-  auto Convert = [](long nsec) {
+  auto Convert = [](long nsec) -> decltype(std::declval<::timeval>().tv_usec) {
     return duration_cast<microseconds>(nanoseconds(nsec)).count();
   };
   struct ::timeval ConvertedTS[2] = {{TS[0].tv_sec, Convert(TS[0].tv_nsec)},




More information about the cfe-commits mailing list