diff mbox series

PR middle-end/89303 add testcase for std::enable_shared_from_this

Message ID 20190214094000.GA1384@redhat.com
State New
Headers show
Series PR middle-end/89303 add testcase for std::enable_shared_from_this | expand

Commit Message

Jonathan Wakely Feb. 14, 2019, 9:40 a.m. UTC
* testsuite/20_util/enable_shared_from_this/89303.cc: New test.

Tested x86_64-linux, committed to trunk.
commit 1a2917b994921926d37c609d386a2cc32ed65735
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Feb 14 09:16:04 2019 +0000

    PR middle-end/89303 add testcase for std::enable_shared_from_this
    
            * testsuite/20_util/enable_shared_from_this/89303.cc: New test.
diff mbox series

Patch

diff --git a/libstdc++-v3/testsuite/20_util/enable_shared_from_this/89303.cc b/libstdc++-v3/testsuite/20_util/enable_shared_from_this/89303.cc
new file mode 100644
index 00000000000..3b23332c35e
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/enable_shared_from_this/89303.cc
@@ -0,0 +1,39 @@ 
+// Copyright (C) 2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-O1" }
+// { dg-do run { target c++11 } }
+
+// PR middle-end/89303
+
+#include <memory>
+
+class blob final: public std::enable_shared_from_this<blob>
+{
+  int* data;
+
+public:
+  blob() { data = new int; }
+  ~blob() { delete data; }
+};
+
+int
+main()
+{
+  std::shared_ptr<blob> tg = std::make_shared<blob>();
+  return tg->shared_from_this().use_count() - 2;
+}