Patchwork [v3] Extend smart ptr assertions to reject void*

login
register
mail settings
Submitter Jonathan Wakely
Date Oct. 31, 2013, 3:06 p.m.
Message ID <CAH6eHdSPu81GvxUGnj=srKGjF_dGv9a3mRrMyu++Y7q9OjUNHQ@mail.gmail.com>
Download mbox | patch
Permalink /patch/287511/
State New
Headers show

Comments

Jonathan Wakely - Oct. 31, 2013, 3:06 p.m.
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.
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>.

Patch

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);
 }