]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
libc++: fix null pointer comparison 1064/head
authorNoah Watkins <noahwatkins@gmail.com>
Fri, 20 Dec 2013 15:56:58 +0000 (09:56 -0600)
committerNoah Watkins <noahwatkins@gmail.com>
Sat, 18 Jan 2014 22:03:58 +0000 (14:03 -0800)
commit1b308b650f750ef40531aad29de6d1a371a4fefa
tree30cc2cfa8f08a8ff1fe82aef59d57a55dd1f070e
parent1fcbddc846476f9497dcec2bc667a50e426311a0
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<MemStore::Object>') 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 <noahwatkins@gmail.com>
src/os/MemStore.cc