Boost logo

Boost :

From: Joaquín Mª López Muñoz (joaquin_at_[hidden])
Date: 2005-06-14 02:48:41

Gennadiy Rozental ha escrito:

> Hi,,
> Here some Boost.Test failures I do not understand:
> 4) token_iterator_test
> Failes at runtime (abort) under gcc- 3.4.4- linux and gcc- 4.0.0- linux. My
> guess it's compler bug. Could somebody confirm?

It is not a compiler bug, but rather an overzealous stdlib implementation:
singular iterators (vg. default initialized iterators from STL containers) are
not required to be copyable, and this is precisely what the stdlib runtime is
detecting. The problem pops up in line 135 of token_iterator_test.cpp:

BOOST_CHECK_EQUAL_COLLECTIONS( tit, end, res, res + sizeof(res)/sizeof(char
const*) );

the my_token_iterator named end holds two std::list<char>::iterator m_begin
and m_end, which by default are singular, so they are not copyable, and neither
is thus end. A possible workaround for this is:

range_token_iterator(const range_token_iterator& other):

This way, default initalized range_token_iterators can be copied around.
There's also a potential problem with one of the range_token_iterator

    explicit range_token_iterator( Iter begin, Iter end = Iter() )
    : m_begin( begin ), m_end( end )

This implies that end is copyable, hence Iter() must produce a non-singular value:

in many cases (for instance, iterators of STL containers) this is not true. If
this constructor is meant to be used for other types iterators, like istream
iterators, then everything's fine.

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo

Boost list run by bdawes at, gregod at, cpdaniel at, john at