This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Library bug - Problem with string(string::reverse_iterator, string::reverse_iterator)
- From: Ryszard Kabatek <Ryszard dot Kabatek at softax dot pl>
- To: libstdc++ at gcc dot gnu dot org
- Date: Mon, 03 Jun 2002 15:55:13 +0200
- Subject: Library bug - Problem with string(string::reverse_iterator, string::reverse_iterator)
- Reply-to: Ryszard dot Kabatek at softax dot pl
The attached sample does not compile with gcc-3.1 (linux), see the error messages below.
The reason is the following check at line 143 in basic_string.tcc:
// NB: Not required, but considered best practice.
if (__builtin_expect(__beg == _InIter(0), 0))
__throw_logic_error("attempt to create string with null pointer");
The compiler is loocking for the constructor that takes an integer value
and of course it cannot find it.
Regards
--
Ryszard Kabatek
g++ -Wall x.cc
x.cc: In function `int main()':
x.cc:5: `string' undeclared (first use this function)
x.cc:5: (Each undeclared identifier is reported only once for each function it
appears in.)
x.cc:5: parse error before `::' token
rysio@rumcajs:~/tmp/xxx >vi x.cc
rysio@rumcajs:~/tmp/xxx >g++ -Wall x.cc
/home/rysio/gcc-3.1/include/g++-v3/bits/basic_string.tcc: In static member
function `static _CharT* std::basic_string<_CharT, _Traits,
_Alloc>::_S_construct(_InIter, _InIter, const _Alloc&,
std::forward_iterator_tag) [with _FwdIter =
std::reverse_iterator<__gnu_cxx::__normal_iterator<char*,
std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >,
_CharT = char, _Traits = std::char_traits<char>, _Alloc =
std::allocator<char>]':
/home/rysio/gcc-3.1/include/g++-v3/bits/basic_string.h:707: instantiated from
`static _CharT* std::basic_string<_CharT, _Traits, _Alloc>::_S_construct_aux(_In
Iter, _InIter, const _Alloc&, __false_type) [with _InIter = std::reverse_iterato
r<__gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<c
har>, std::allocator<char> > > >, _CharT = char, _Traits = std::char_traits<char
>, _Alloc = std::allocator<char>]'
/home/rysio/gcc-3.1/include/g++-v3/bits/basic_string.h:724: instantiated from
`static _CharT* std::basic_string<_CharT, _Traits, _Alloc>::_S_construct(_InIter
, _InIter, const _Alloc&) [with _InIter = std::reverse_iterator<__gnu_cxx::__nor
mal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocat
or<char> > > >, _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::a
llocator<char>]'
/home/rysio/gcc-3.1/include/g++-v3/bits/basic_string.tcc:241: instantiated fro
m `std::basic_string<_CharT, _Traits, _Alloc>::basic_string(_InputIter, _InputIt
er, const _Alloc&) [with _InputIterator = std::reverse_iterator<__gnu_cxx::__nor
mal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocat
or<char> > > >, _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::a
llocator<char>]'
x.cc:8: instantiated from here
/home/rysio/gcc-3.1/include/g++-v3/bits/basic_string.tcc:143: no matching
function for call to `
std::reverse_iterator<__gnu_cxx::__normal_iterator<char*,
std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >::
reverse_iterator(int)'
/home/rysio/gcc-3.1/include/g++-v3/bits/stl_iterator.h:123: candidates are:
std::reverse_iterator<_Iterator>::reverse_iterator(const
std::reverse_iterator<_Iterator>&) [with _Iterator =
__gnu_cxx::__normal_iterator<char*, std::basic_string<char,
std::char_traits<char>, std::allocator<char> > >]
/home/rysio/gcc-3.1/include/g++-v3/bits/stl_iterator.h:117:
std::reverse_iterator<_Iterator>::reverse_iterator(_Iterator) [with
_Iterator = __gnu_cxx::__normal_iterator<char*, std::basic_string<char,
std::char_traits<char>, std::allocator<char> > >]
/home/rysio/gcc-3.1/include/g++-v3/bits/stl_iterator.h:111:
std::reverse_iterator<_Iterator>::reverse_iterator() [with _Iterator =
__gnu_cxx::__normal_iterator<char*, std::basic_string<char,
std::char_traits<char>, std::allocator<char> > >]
#include <string>
int main()
{
using std::string;
string::reverse_iterator i1;
string::reverse_iterator i2;
string s(i1, i2);
}