This is an archive of the discontinued LLVM Phabricator instance.

[libc++] [test] Detect an improperly noexcept'ed __decay_copy.
ClosedPublic

Authored by Quuxplusone on Apr 11 2021, 3:42 PM.

Details

Summary
`__decay_copy` is used by `std::thread`'s constructor to copy its arguments
into the new thread. If `__decay_copy` claims to be noexcept, but then
copying the argument does actually throw, we'd call std::terminate instead
of passing this test. (And I've verified that adding an unconditional `noexcept`
to `__decay_copy` does indeed fail this test.)

(This came out of review comments on D100255.)

Diff Detail

Event Timeline

Quuxplusone requested review of this revision.Apr 11 2021, 3:42 PM
Quuxplusone created this revision.
Herald added 1 blocking reviewer(s): Restricted Project. · View Herald TranscriptApr 11 2021, 3:42 PM
cjdb added a comment.Apr 11 2021, 4:21 PM

Maybe it's worth cleaning up __decay_copy in this patch too? It's probably best if we commit separately to D100225.

@cjdb wrote: "Maybe it's worth cleaning up __decay_copy in this patch too?"

__decay_copy is an internal implementation detail of libc++; making it conditionally-noexcept would just slow down the compile for no visible benefit. Therefore I don't propose to make __decay_copy conditionally-noexcept in this patch. The point of this patch is just to add a test that will fail if anyone puts a (too blatantly) wrong conditional-noexcept on it.

Relevant: https://quuxplusone.github.io/blog/2018/06/12/attribute-noexcept-verify/

Fix C++03 — in that mode we support std::thread t(f); but not std::thread t(f, args...).

ldionne accepted this revision.Apr 12 2021, 8:41 AM
This revision is now accepted and ready to land.Apr 12 2021, 8:41 AM