Page MenuHomePhabricator

static_assert inside make_shared when the object is not constructible

Authored by mclow.lists on Jan 3 2017, 1:57 PM.


Summary shows a scenario where make_shared of a class with a protected constructor compiles successfully (it should fail).

This is because we apply an empty-base class optimization to the shared_ptr.

This is one way to solve the problem; there are probably others.
However, this works, and passes all the tests (including the two new ones I just added).

Diff Detail

Event Timeline

mclow.lists updated this revision to Diff 82947.Jan 3 2017, 1:57 PM
mclow.lists retitled this revision from to static_assert inside make_shared when the object is not constructible.
mclow.lists updated this object.
mclow.lists added a reviewer: EricWF.
mclow.lists added a subscriber: cfe-commits.
mclow.lists added inline comments.

Whoops. This change doesn't belong here.
But it fixes a problem running LIT to test libc++ on Mac OS when building with the system libc++abi.

mclow.lists updated this object.Jan 3 2017, 2:00 PM
EricWF accepted this revision.Jan 4 2017, 2:45 PM
EricWF edited edge metadata.

LGTM minus the changes, but those were discussed offline.

Also I prefer to write new .fail.cpp tests using clang verify. It allows fail tests to contain more than one test case, and it verifies the diagnostic messages omitted. I re-wrote your two failure tests as a single test using -verify here.

This revision is now accepted and ready to land.Jan 4 2017, 2:45 PM
mclow.lists closed this revision.Dec 4 2017, 8:10 PM

Committed as revision 319736