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

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


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: eaadc451566f0d1aec873b7fe8b1a9dc3a7b29bd
      https://github.com/llvm/llvm-project/commit/eaadc451566f0d1aec873b7fe8b1a9dc3a7b29bd
  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




More information about the All-commits mailing list