[v3 patch] Extend smart ptr assertions to reject void*
Jonathan Wakely
jwakely.gcc@gmail.com
Thu Oct 31 16:05:00 GMT 2013
On 30 October 2013 19:49, Jonathan Wakely wrote:
> Because of the GNU extension that allows sizeof(void) we fail to
> reject ill-formed programs. This patch fixes that.
>
> 2013-10-30 Jonathan Wakely <jwakely.gcc@gmail.com>
>
> * include/bits/shared_ptr (__shared_ptr): Assert non-void pointer.
> * include/bits/shared_ptr (default_delete): Likewise.
> * include/backward/auto_ptr.h (__shared_ptr(auto_ptr&&)): Likewise.
> * testsuite/20_util/shared_ptr/cons/58839.cc: Do not use
> default_delete<void>.
> * testsuite/20_util/shared_ptr/cons/void_neg.cc: New.
> * testsuite/20_util/default_delete/void_neg.cc: New.
> * testsuite/20_util/shared_ptr/cons/43820_neg.cc: Adjust line numbers.
> * testsuite/20_util/unique_ptr/assign/48635_neg.cc: Likewise.
>
> Tested x86_64-linux, committed to trunk.
And this just corrects the recently-added testcase on the 4.8 branch.
-------------- next part --------------
commit 969f89d2ee9fdaef87a94efe116febac2a47565a
Author: Jonathan Wakely <jwakely.gcc@gmail.com>
Date: Thu Oct 31 14:35:51 2013 +0000
* testsuite/20_util/shared_ptr/cons/58839.cc: Do not use
default_delete<void>.
diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/58839.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/58839.cc
index 6ad2564..f78a07f 100644
--- a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/58839.cc
+++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/58839.cc
@@ -22,8 +22,12 @@
// libstdc++/58839
+struct D {
+ void operator()(void*) const noexcept { }
+};
+
void test01()
{
- std::unique_ptr<void> y;
+ std::unique_ptr<void, D> y;
std::shared_ptr<void> x = std::move(y);
}
More information about the Libstdc++
mailing list