[LLVMbugs] [Bug 20077] New: clang errors when using Objective-C objects in C++ containers.

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Jun 18 08:12:57 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=20077

            Bug ID: 20077
           Summary: clang errors when using Objective-C objects in C++
                    containers.
           Product: clang
           Version: unspecified
          Hardware: Other
                OS: FreeBSD
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: chmeeedalf at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

When compiling the following program using: clang++ -c test.mm -O0 -fobjc-arc


#include <unordered_map>

extern id foo;
extern id bar;

int main()
{
        std::unordered_map<__strong id,int> idmap;

        idmap[foo] = 0;
}

I see the following errors:

/usr/include/c++/v1/memory:3399:13: error: '__t' is unavailable: this system
field has retaining ownership
        __u.__t = __v;
            ^
/usr/include/c++/v1/unordered_map:384:17: note: in instantiation of member
function 'std::__1::hash<id>::operator()' requested here
        {return static_cast<const _Hash&>(*this)(__x);}
                ^
/usr/include/c++/v1/__hash_table:2020:21: note: in instantiation of member
function 'std::__1::__unordered_map_hasher<id, std::__1::__hash_value_type<id,
int>, std::__1::hash<id>, true>::operator()' requested here
    size_t __hash = hash_function()(__k);
                    ^
/usr/include/c++/v1/unordered_map:970:69: note: in instantiation of function
template specialization 'std::__1::__hash_table<std::__1::__hash_value_type<id,
int>, std::__1::__unordered_map_hasher<id,
      std::__1::__hash_value_type<id, int>, std::__1::hash<id>, true>,
std::__1::__unordered_map_equal<id, std::__1::__hash_value_type<id, int>,
std::__1::equal_to<id>, true>,
      std::__1::allocator<std::__1::__hash_value_type<id, int> > >::find<id>'
requested here
    iterator       find(const key_type& __k)       {return __table_.find(__k);}
                                                                    ^
/usr/include/c++/v1/unordered_map:1360:20: note: in instantiation of member
function 'std::__1::unordered_map<id, int, std::__1::hash<id>,
std::__1::equal_to<id>, std::__1::allocator<std::__1::pair<const id, int> >
      >::find' requested here
    iterator __i = find(__k);
                   ^
test.mm:10:7: note: in instantiation of member function
'std::__1::unordered_map<id, int, std::__1::hash<id>, std::__1::equal_to<id>,
std::__1::allocator<std::__1::pair<const id, int> > >::operator[]' requested
here
        idmap[foo] = 0;
             ^
/usr/include/c++/v1/memory:3396:18: note: declaration has been explicitly
marked unavailable here
            _Tp* __t;
                 ^
In file included from test.mm:1:
/usr/include/c++/v1/unordered_map:1338:36: error: call to 'addressof' is
ambiguous
    __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.first),
__k);
                                   ^~~~~~~~~~~~~~~~
/usr/include/c++/v1/__config:341:15: note: expanded from macro '_VSTD'
#define _VSTD std::_LIBCPP_NAMESPACE
              ^
/usr/include/c++/v1/unordered_map:1363:25: note: in instantiation of member
function 'std::__1::unordered_map<id, int, std::__1::hash<id>,
std::__1::equal_to<id>, std::__1::allocator<std::__1::pair<const id, int> >
      >::__construct_node_with_key' requested here
    __node_holder __h = __construct_node_with_key(__k);
                        ^
test.mm:10:7: note: in instantiation of member function
'std::__1::unordered_map<id, int, std::__1::hash<id>, std::__1::equal_to<id>,
std::__1::allocator<std::__1::pair<const id, int> > >::operator[]' requested
here
        idmap[foo] = 0;
             ^
/usr/include/c++/v1/__functional_base:96:1: note: candidate function [with _Tp
= const id]
addressof(__strong _Tp& __x) _NOEXCEPT
^
/usr/include/c++/v1/__functional_base:122:1: note: candidate function [with _Tp
= const id]
addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT
^
/usr/include/c++/v1/__functional_base:83:1: note: candidate function [with _Tp
= const id]
addressof(_Tp& __x) _NOEXCEPT
^
In file included from test.mm:1:
/usr/include/c++/v1/unordered_map:522:44: error: call to 'addressof' is
ambiguous
            __alloc_traits::destroy(__na_,
_VSTD::addressof(__p->__value_.__cc.first));
                                           ^~~~~~~~~~~~~~~~
/usr/include/c++/v1/__config:341:15: note: expanded from macro '_VSTD'
#define _VSTD std::_LIBCPP_NAMESPACE
              ^
/usr/include/c++/v1/memory:2625:13: note: in instantiation of member function
'std::__1::__hash_map_node_destructor<std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<id,
int>, void *> >
      >::operator()' requested here
            __ptr_.second()(__tmp);
            ^
/usr/include/c++/v1/memory:2593:46: note: in instantiation of member function
'std::__1::unique_ptr<std::__1::__hash_node<std::__1::__hash_value_type<id,
int>, void *>,
     
std::__1::__hash_map_node_destructor<std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<id,
int>, void *> > > >::reset' requested here
    _LIBCPP_INLINE_VISIBILITY ~unique_ptr() {reset();}
                                             ^
/usr/include/c++/v1/unordered_map:1363:25: note: in instantiation of member
function
'std::__1::unique_ptr<std::__1::__hash_node<std::__1::__hash_value_type<id,
int>, void *>,

      >::operator()' requested here
            __ptr_.second()(__tmp);
            ^
/usr/include/c++/v1/memory:2593:46: note: in instantiation of member function
'std::__1::unique_ptr<std::__1::__hash_node<std::__1::__hash_value_type<id,
int>, void *>,
     
std::__1::__hash_map_node_destructor<std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<id,
int>, void *> > > >::reset' requested here
    _LIBCPP_INLINE_VISIBILITY ~unique_ptr() {reset();}
                                             ^
/usr/include/c++/v1/unordered_map:1363:25: note: in instantiation of member
function
'std::__1::unique_ptr<std::__1::__hash_node<std::__1::__hash_value_type<id,
int>, void *>,
     
std::__1::__hash_map_node_destructor<std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<id,
int>, void *> > > >::~unique_ptr' requested here
    __node_holder __h = __construct_node_with_key(__k);
                        ^
test.mm:10:7: note: in instantiation of member function
'std::__1::unordered_map<id, int, std::__1::hash<id>, std::__1::equal_to<id>,
std::__1::allocator<std::__1::pair<const id, int> > >::operator[]' requested
here
        idmap[foo] = 0;
             ^
/usr/include/c++/v1/__functional_base:96:1: note: candidate function [with _Tp
= const id]
addressof(__strong _Tp& __x) _NOEXCEPT
^
/usr/include/c++/v1/__functional_base:122:1: note: candidate function [with _Tp
= const id]
addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT
^
/usr/include/c++/v1/__functional_base:83:1: note: candidate function [with _Tp
= const id]
addressof(_Tp& __x) _NOEXCEPT
^
3 errors generated.



This compiled with clang 3.3 in FreeBSD, and the associated libc++.  This
failure occurs with

FreeBSD clang version 3.4 (tags/RELEASE_34/final 197956) 20140216
And the associated libc++

This error also does not occur when -fobjc-arc is not specified.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140618/639078dc/attachment.html>


More information about the llvm-bugs mailing list