<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - clang errors when using Objective-C objects in C++ containers."
   href="http://llvm.org/bugs/show_bug.cgi?id=20077">20077</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang errors when using Objective-C objects in C++ containers.
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>FreeBSD
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Frontend
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>chmeeedalf@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>