This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Fix chrono::duration constructor constraint
ClosedPublic

Authored by ldionne on Feb 3 2022, 6:50 AM.

Details

Reviewers
tiagoma
Group Reviewers
Restricted Project
Commits
rGeaadc451566f: [libc++] Fix chrono::duration constructor constraint
Summary

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, ex:

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()};

Diff Detail

Event Timeline

tiagoma requested review of this revision.Feb 3 2022, 6:50 AM
tiagoma created this revision.
Herald added a reviewer: Restricted Project. · View Herald TranscriptFeb 3 2022, 6:50 AM
ldionne requested changes to this revision.Feb 3 2022, 6:59 AM

Thanks for your patch!

Can you please add a test for this? The correct file seems like it should be libcxx/test/std/utilities/time/time.duration/time.duration.cons/rep.pass.cpp.

Also, if you need someone to commit this for you, please provide Author Name <email@domain> for commit attribution.

This revision now requires changes to proceed.Feb 3 2022, 6:59 AM
tiagoma updated this revision to Diff 405633.Feb 3 2022, 7:17 AM

Thanks for your patch!

Can you please add a test for this? The correct file seems like it should be libcxx/test/std/utilities/time/time.duration/time.duration.cons/rep.pass.cpp.

Also, if you need someone to commit this for you, please provide Author Name <email@domain> for commit attribution.

"Tiago Macarios <tiagomacarios@gmail.com>"

ldionne commandeered this revision.Feb 3 2022, 7:38 AM
ldionne edited reviewers, added: tiagoma; removed: ldionne.

Commandeer per offline discussion.

ldionne updated this revision to Diff 405638.Feb 3 2022, 7:39 AM

Fix the test.

tiagoma accepted this revision.Feb 3 2022, 8:56 AM
This revision was not accepted when it landed; it landed in state Needs Review.Feb 3 2022, 3:07 PM
This revision was automatically updated to reflect the committed changes.