This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] missing template argument in __weak_ptr::lock


Hi everyone,

__weak_ptr<Tp, Lp>::lock() cannot be instantiated when Lp !=
__default_lock_policy, as shown by the second of these new tests. The
other test is to ensure something similar doesn't happen with
__shared_ptr.

The errors are of the form:
/src/gcc/build/x86_64-unknown-linux-gnu/libstdc++-v3/include/tr1_impl/boost_shared_ptr.h:859:
error: conversion from 'std::tr1::__shared_ptr<int, _S_atomic>' to
non-scalar type 'std::tr1::__shared_ptr<int, _S_single>' requested

Are the new tests OK?  There is no explicit instantiation for
__shared_ptr<void, Lp> because its operator* can't be instantiated.

tested x86_64/linux, OK for mainline?
I don't have a 4.2 compiler built to test yet, but I guess this should
also go on that branch once 4.2.2 is released.

Jon
Index: include/tr1_impl/boost_shared_ptr.h
===================================================================
--- include/tr1_impl/boost_shared_ptr.h	(revision 128305)
+++ include/tr1_impl/boost_shared_ptr.h	(working copy)
@@ -856,7 +856,7 @@
 	    // Q: How can we get here?
 	    // A: Another thread may have invalidated r after the
 	    //    use_count test above.
-	    return __shared_ptr<element_type>();
+	    return __shared_ptr<element_type, _Lp>();
 	  }
 	
 #else
// Copyright (C) 2007 Free Software Foundation
//
// 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 2, 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 COPYING.  If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.

// TR1 2.2.2 Template class shared_ptr [tr.util.smartptr.shared]

#include <tr1/memory>
#include <testsuite_tr1.h>

// { dg-do compile }

// Check the _S_single lock policy can be instantiated. For a thread-enabled
// library this checks the templates can be instantiated for non-default
// lock policy, for a single-threaded lib this is redundant but harmless.
using namespace __gnu_test;
using std::tr1::__shared_ptr;
using std::tr1::_S_single;
template class __shared_ptr<int, _S_single>;
template class __shared_ptr<ClassType, _S_single>;
template class __shared_ptr<IncompleteClass, _S_single>;
// Copyright (C) 2007 Free Software Foundation
//
// 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 2, 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 COPYING.  If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.

// TR1 2.2.4 Template class weak_ptr [tr.util.smartptr.weak]

#include <tr1/memory>
#include <testsuite_tr1.h>

// { dg-do compile }

// Check the _S_single lock policy can be instantiated. For a thread-enabled
// library this checks the templates can be instantiated for non-default
// lock policy, for a single-threaded lib this is redundant but harmless.
using namespace __gnu_test;
using std::tr1::__weak_ptr;
using std::tr1::_S_single;
template class __weak_ptr<int, _S_single>;
template class __weak_ptr<void, _S_single>;
template class __weak_ptr<ClassType, _S_single>;
template class __weak_ptr<IncompleteClass, _S_single>;

Attachment: ChangeLog
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]