Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(947)

Unified Diff: base/memory/scoped_ptr_unittest.nc

Issue 9958150: Make sure that scoped_ptr<> cannot be used with ref-counted objects. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/memory/scoped_ptr.h ('k') | chrome/common/service_process_util_mac.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/scoped_ptr_unittest.nc
diff --git a/base/memory/scoped_ptr_unittest.nc b/base/memory/scoped_ptr_unittest.nc
index 841d03c7eda9fa3f243e2d971b2a9feab7fe052d..30a332edcd469e565089f06922300fc5a3e64423 100644
--- a/base/memory/scoped_ptr_unittest.nc
+++ b/base/memory/scoped_ptr_unittest.nc
@@ -4,6 +4,7 @@
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/ref_counted.h"
namespace {
@@ -13,6 +14,9 @@ class Parent {
class Child : public Parent {
};
+class RefCountedClass : public base::RefCountedThreadSafe<RefCountedClass> {
+};
+
} // namespace
#if defined(NCTEST_NO_PASSAS_DOWNCAST) // [r"invalid conversion from"]
@@ -21,4 +25,11 @@ scoped_ptr<Child> DowncastUsingPassAs(scoped_ptr<Parent> object) {
return object.PassAs<Child>();
}
+#elif defined(NCTEST_NO_REF_COUNTED_SCOPED_PTR) // [r"creating array with negative size"]
+
+// scoped_ptr<> should not work for ref-counted objects.
+void WontCompile() {
+ scoped_ptr<RefCountedClass> x;
+}
+
#endif
« no previous file with comments | « base/memory/scoped_ptr.h ('k') | chrome/common/service_process_util_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698