https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61946

            Bug ID: 61946
           Summary: rope construction, passing allocator referenct without
                    const
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: stuff at trez dot name

Include file ext/rope of libstdc++ in revision 124427, there was a change with
passing allocator through in-template functions, in my interest is constructor:

rope(char_producer<_CharT> *, size_t, bool, const allocator_type& )

which calls _S_new_RopeFunction, the change was with adding reference to 4
parameter:

from:
 _S_new_RopeFunction(char_producer<_CharT>* __f, size_t __size, bool __d,
allocator_type __a

to:
 _S_new_RopeFunction(char_producer<_CharT>* __f, size_t __size, bool __d,
allocator_type& __a


and it makes problem with compilation of example code:

#include <ext/rope>

class empty_char_prod : public __gnu_cxx::char_producer<char>
{
  public:
    virtual void operator()(size_t start_pos, size_t len, char* buffer)
    {}
};

int main ()
{
    empty_char_prod* ecp = new empty_char_prod;
    __gnu_cxx::crope excrope ( ecp, 10L, true );

    return 0;
}

compilation on gcc version 4.9.1 (Debian 4.9.1-1):
/usr/include/c++/4.9/ext/rope: In instantiation of ‘__gnu_cxx::rope<_CharT,
_Alloc>::rope(__gnu_cxx::char_producer<_CharT>*, std::size_t, bool, const
allocator_type&) [with _CharT = char; _Alloc = std::allocator<char>;
std::size_t = long unsigned int; __gnu_cxx::rope<_CharT,
_Alloc>::allocator_type = std::allocator<char>]’:
./cropy.cc:17:47:   required from here
/usr/include/c++/4.9/ext/rope:1880:57: error: no matching function for call to
‘__gnu_cxx::rope<char>::_S_new_RopeFunction(__gnu_cxx::char_producer<char>*&,
std::size_t&, bool&, const allocator_type&)’
    0 : _S_new_RopeFunction(__fn, __len, __delete_fn, __a);
                                                         ^
/usr/include/c++/4.9/ext/rope:1880:57: note: candidate is:
/usr/include/c++/4.9/ext/rope:1673:7: note: static __gnu_cxx::rope<_CharT,
_Alloc>::_RopeFunction* __gnu_cxx::rope<_CharT,
_Alloc>::_S_new_RopeFunction(__gnu_cxx::char_producer<_CharT>*, std::size_t,
bool, __gnu_cxx::rope<_CharT, _Alloc>::allocator_type&) [with _CharT = char;
_Alloc = std::allocator<char>; __gnu_cxx::rope<_CharT, _Alloc>::_RopeFunction =
__gnu_cxx::_Rope_RopeFunction<char, std::allocator<char> >; std::size_t = long
unsigned int; __gnu_cxx::rope<_CharT, _Alloc>::allocator_type =
std::allocator<char>]
       _S_new_RopeFunction(char_producer<_CharT>* __f,
       ^
/usr/include/c++/4.9/ext/rope:1673:7: note:   no known conversion for argument
4 from ‘const allocator_type {aka const std::allocator<char>}’ to
‘__gnu_cxx::rope<char>::allocator_type& {aka std::allocator<char>&}’


I thing the change should by from copy to const reference, like this:
 _S_new_RopeFunction(char_producer<_CharT>* __f, size_t __size, bool __d, const
allocator_type& __a

Reply via email to