[LLVMbugs] [Bug 9672] New: Compile error with reverse_iterator::operator->

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Apr 10 18:53:36 PDT 2011


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

           Summary: Compile error with reverse_iterator::operator->
           Product: libc++
           Version: unspecified
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
        AssignedTo: hhinnant at apple.com
        ReportedBy: maarten at treewalker.org
                CC: llvmbugs at cs.uiuc.edu


Created an attachment (id=6429)
 --> (http://llvm.org/bugs/attachment.cgi?id=6429)
Test case

Tested with SVN revision 127499, on Mac OS X 10.6.

If I compile the attached test case against libstdc++, it compiles and links
without problems. But if I compile it against libc++, I get a compile error:

$ clang++ -stdlib=libc++ reverse_iterator.cc 
In file included from reverse_iterator.cc:5:
In file included from /usr/include/c++/v1/iostream:38:
In file included from /usr/include/c++/v1/ios:216:
In file included from /usr/include/c++/v1/__locale:15:
In file included from /usr/include/c++/v1/string:423:
In file included from /usr/include/c++/v1/algorithm:594:
In file included from /usr/include/c++/v1/memory:526:
/usr/include/c++/v1/iterator:529:67: error: cannot initialize return object of
type 'pointer' (aka
      'std::__1::pair<const int, std::__1::basic_string<char> > *') with an
rvalue of type
      'const value_type *' (aka 'const pair<__key_type, __mapped_type> *')
    _LIBCPP_INLINE_VISIBILITY pointer  operator->() const {return
&(operator*());}
                                                                 
^~~~~~~~~~~~~~
reverse_iterator.cc:19:25: note: in instantiation of member function
     
'std::__1::reverse_iterator<std::__1::__map_const_iterator<std::__1::__tree_const_iterator<std::__1::pair<int,
      std::__1::basic_string<char> >, const
std::__1::__tree_node<std::__1::pair<int,
      std::__1::basic_string<char> >, void *> *, long> > >::operator->'
requested here
    cout << rev_iterator->first << " " << rev_iterator->second << "\n";
                        ^
1 error generated.

It is possible to work around this problem by replacing "it->x" by "(*it).x".

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list