This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] [test] Fix test bugs in string.cons/copy_alloc.pass.cpp.
ClosedPublic

Authored by BillyONeal on Mar 29 2019, 7:02 PM.

Details

Summary

Fixed the inability to properly rebind the testing allocator, by making the
inner alloc_impl type a plain struct and making the operations templates. Before
rebind failed to compile complaining that a alloc_impl<T>* was not convertible
to an alloc_impl<U>*.

This enables the test to pass for MSVC++ once we provide the strong guarantee
for the copy assignment operator.

Reviewed as https://reviews.llvm.org/D60023

Diff Detail

Event Timeline

BillyONeal created this revision.Mar 29 2019, 7:02 PM
BillyONeal added inline comments.Mar 30 2019, 2:21 AM
test/std/strings/basic.string/string.cons/copy_alloc.pass.cpp
123

We still fail this test in debug mode because we need to allocate a new _Container_proxy from imp2 in this assignment. Should this be libcxx_assert?

BillyONeal marked 2 inline comments as done.Mar 30 2019, 2:43 AM
BillyONeal added inline comments.
test/std/strings/basic.string/string.cons/copy_alloc.pass.cpp
123

Hmmm this is copy assignment, not move assignment, so we still have a bug. I should not try writing CR comments at 2 in the morning.

BillyONeal marked an inline comment as done.Mar 30 2019, 2:50 AM
BillyONeal added inline comments.
test/std/strings/basic.string/string.cons/copy_alloc.pass.cpp
125

This particular assert tests that the copy assignment operator provides the strong exception safety guarantee, but the standard requires only the basic guarantee. Should this be _LIBCXX_ASSERT?

ldionne requested changes to this revision.Apr 1 2019, 9:37 AM
ldionne added inline comments.
test/std/strings/basic.string/string.cons/copy_alloc.pass.cpp
125

Yes, I think it should (ideally with a short comment).

This revision now requires changes to proceed.Apr 1 2019, 9:37 AM
BillyONeal updated this revision to Diff 193157.Apr 1 2019, 1:02 PM
BillyONeal edited the summary of this revision. (Show Details)

Fix asserts for the strong EH guarantee.

BillyONeal marked 2 inline comments as done.Apr 1 2019, 1:09 PM
CaseyCarter requested changes to this revision.Apr 1 2019, 5:53 PM
CaseyCarter added a subscriber: CaseyCarter.
CaseyCarter added inline comments.
test/std/strings/basic.string/string.cons/copy_alloc.pass.cpp
128

LIBCPP_ASSERT(s1 == p1) (NB: no leading underscore) in test code.

This revision now requires changes to proceed.Apr 1 2019, 5:53 PM
BillyONeal updated this revision to Diff 193216.Apr 1 2019, 6:40 PM

Fixed misspelled test macro.

BillyONeal marked an inline comment as done.Apr 1 2019, 6:40 PM
CaseyCarter resigned from this revision.Apr 1 2019, 7:08 PM
ldionne accepted this revision.Apr 2 2019, 9:32 AM
This revision is now accepted and ready to land.Apr 2 2019, 9:32 AM

Tim Song suggests that http://eel.is/c++draft/string.require#2 indicates that basic_string actually does need to provide the strong guarantee here. While I think that wording is a mess I think I'll fix our basic_string to do that instead of that part of this change.

BillyONeal closed this revision.Apr 2 2019, 5:03 PM
BillyONeal updated this revision to Diff 193393.
BillyONeal retitled this revision from [libcxx] [test] Fix inability to rebind poca_alloc in string.cons/copy_alloc.pass.cpp. to [libcxx] [test] Fix test bugs in string.cons/copy_alloc.pass.cpp..
BillyONeal edited the summary of this revision. (Show Details)

Committed r357545