diff options
author | Will Hawkins <hawkinsw@obs.cr> | 2023-12-04 20:59:44 +0000 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2023-12-05 16:40:43 +0000 |
commit | 9fff752695648b06a977b046990d69d41a1bf702 (patch) | |
tree | 585ac2f43793392b0f5a782eef65ca8a2dc85c1a | |
parent | e5153e7d63b4cd9a3df490809c4f3fe1e94d3d37 (diff) | |
download | gcc-9fff752695648b06a977b046990d69d41a1bf702.zip gcc-9fff752695648b06a977b046990d69d41a1bf702.tar.gz gcc-9fff752695648b06a977b046990d69d41a1bf702.tar.bz2 |
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>
-rw-r--r-- | libstdc++-v3/testsuite/20_util/smartptr.adapt/inout_ptr/2.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/20_util/smartptr.adapt/inout_ptr/2.cc b/libstdc++-v3/testsuite/20_util/smartptr.adapt/inout_ptr/2.cc index ca60762..b4a2d95 100644 --- a/libstdc++-v3/testsuite/20_util/smartptr.adapt/inout_ptr/2.cc +++ b/libstdc++-v3/testsuite/20_util/smartptr.adapt/inout_ptr/2.cc @@ -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(); } |