Page MenuHomePhabricator

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

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


`__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.Sun, Apr 11, 3:42 PM
Quuxplusone created this revision.
Herald added 1 blocking reviewer(s): Restricted Project. · View Herald TranscriptSun, Apr 11, 3:42 PM
cjdb added a comment.Sun, Apr 11, 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.

Quuxplusone accepted this revision as: Quuxplusone.Mon, Apr 12, 5:58 AM

@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.


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

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