[all-commits] [llvm/llvm-project] 749fb3: [libc++] Fix chrono::duration constructor constraint

Tiago via All-commits all-commits at lists.llvm.org
Thu Feb 3 15:10:11 PST 2022


  Branch: refs/heads/release/14.x
  Home:   https://github.com/llvm/llvm-project
  Commit: 749fb39c8e8ac4aa8460aac4926cad42153cc9d1
      https://github.com/llvm/llvm-project/commit/749fb39c8e8ac4aa8460aac4926cad42153cc9d1
  Author: Tiago Macarios <tiagomacarios at gmail.com>
  Date:   2022-02-03 (Thu, 03 Feb 2022)

  Changed paths:
    M libcxx/include/__chrono/duration.h
    M libcxx/test/std/utilities/time/time.duration/time.duration.cons/rep.pass.cpp

  Log Message:
  -----------
  [libc++] Fix chrono::duration constructor constraint

As per [time.duration.cons]/1, the constructor constraint should be on
const Rep2&. As it is now the code will fail to compile in certain
cases, for example (https://godbolt.org/z/c7fPrcTYM):

     struct S{
          operator int() const&& noexcept = delete;
          operator int() const& noexcept;
     };

     const S &fun();

     auto k = std::chrono::microseconds{fun()};

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

(cherry picked from commit eaadc451566f0d1aec873b7fe8b1a9dc3a7b29bd)




More information about the All-commits mailing list