From 1b308b650f750ef40531aad29de6d1a371a4fefa Mon Sep 17 00:00:00 2001 From: Noah Watkins Date: Fri, 20 Dec 2013 09:56:58 -0600 Subject: [PATCH] libc++: fix null pointer comparison This error is thrown when comparing a shared_ptr to NULL. To resolve this we just use shared_ptr::operator bool that checks if the stored pointer is null. In C++11 the shared_ptr can be compared to nullptr, but as of yet I have not come up with a good compatibility fix. Details: os/MemStore.cc:259:30: error: use of overloaded operator '!=' is ambiguous (with operand types 'ObjectRef' (aka 'shared_ptr') and 'long') return (c->get_object(oid) != __null); ~~~~~~~~~~~~~~~~~~ ^ ~~~~~~ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/memory:4787:1: note: candidate function [with _Tp = MemStore::Object] operator!=(const shared_ptr<_Tp>& __x, nullptr_t) throw() ^ os/MemStore.cc:259:30: note: built-in candidate operator!=(int, long) return (c->get_object(oid) != __null); ^ os/MemStore.cc:259:30: note: built-in candidate operator!=(unsigned __int128, long) os/MemStore.cc:259:30: note: built-in candidate operator!=(unsigned long long, long) ..... 1 error generated. make[3]: *** [os/MemStore.lo] Error 1 Signed-off-by: Noah Watkins --- src/os/MemStore.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/os/MemStore.cc b/src/os/MemStore.cc index 4bcd93f406a..fd6a7d5a90c 100644 --- a/src/os/MemStore.cc +++ b/src/os/MemStore.cc @@ -256,7 +256,9 @@ bool MemStore::exists(coll_t cid, const ghobject_t& oid) return false; RWLock::RLocker l(c->lock); - return (c->get_object(oid) != NULL); + // Perform equivalent of c->get_object_(oid) != NULL. In C++11 the + // shared_ptr needs to be compared to nullptr. + return (bool)c->get_object(oid); } int MemStore::stat( -- 2.47.3