libstdc++: Add test for LWG Issue 3897
Add a test to verify that the implementation of inout_ptr is not vulnerable to LWG Issue 3897. libstdc++-v3/ChangeLog: * testsuite/20_util/smartptr.adapt/inout_ptr/2.cc: Add check for LWG Issue 3897. Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
This commit is contained in:
parent
e5153e7d63
commit
9fff752695
1 changed files with 15 additions and 0 deletions
|
@ -96,7 +96,22 @@ test_unique_ptr()
|
|||
VERIFY( upbd->id == 2 );
|
||||
}
|
||||
|
||||
void
|
||||
test_lwg3897()
|
||||
{
|
||||
// Verify that implementation handles LWG Issue 3897
|
||||
auto nuller = [](int** p) {
|
||||
delete *p;
|
||||
*p = nullptr;
|
||||
};
|
||||
int* i = new int{5};
|
||||
nuller(std::inout_ptr(i));
|
||||
|
||||
VERIFY( i == nullptr );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_unique_ptr();
|
||||
test_lwg3897();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue