[PATCH] D50860: [libc++][test] Remove non-portable assumption that thread's constructor allocates with ::new

Casey Carter via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 26 11:03:29 PDT 2018


CaseyCarter added a comment.

I'll put this explanation in the comments and push a change.



================
Comment at: test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp:121
 //    allocations.
+int numAllocs;
+
----------------
EricWF wrote:
> Why?
`main` non-portably assumes that thread creation results in at least one call to `::operator new`. This change fixes that assumption by counting the number of calls to `::operator new` here for creation of a do-nothing thread, and communicating that count to `main` via `numAllocs`.


================
Comment at: test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp:171
 #ifndef TEST_HAS_NO_EXCEPTIONS
-    {
+    if (numAllocs > 0) {
         try
----------------
EricWF wrote:
> I'm not sure I understand this change either.
> 
If thread creation in `test_throwing_new_during_thread_creation` resulted in `0` calls to `::operator new`, the expectation is that the same will occur here when we create a thread. If `::operator new` isn't called, it can't throw the exception this test is expecting to catch.


https://reviews.llvm.org/D50860





More information about the cfe-commits mailing list