Boost logo

Boost :

From: Beman Dawes (bdawes_at_[hidden])
Date: 2006-01-15 11:05:15

"David Whetstone" <mr.fixit_at_[hidden]> wrote in message
> While investigating basic_path::append (please see my previous posts), I
> found something a bit suspect.
> template<class String, class Traits> template <class InputIterator>
> basic_path<String, Traits> & basic_path<String, Traits>::append(
> InputIterator first, InputIterator last )
> {
> if ( detail::is_separator<path_type>( *first )
> && detail::is_separator<path_type>( *(first+1) )
> && *(first+2) == colon<path_type>::value ) first += 3;
> What if first == last? Worse, what if 'last' is the typical
> past-the-end (dereferencing undefined) value?

Nice catch! The code was a cut-and-past from the previous function, where
the input was zero-terminated, and thus correct in that context but not in
the additional context.

There was also a more subtle bug. The code was supposed to require only
input iterators, yet in fact required random access iterators. If, as seems
likely, C++0x gets concept checking then this kind of requirements-failure
error will get detected by the compiler.

> Consider the following test-cases:

I've added these - thanks!

It will be a couple of days before the fix appears in CVS - it will be part
of a update addressing several other issues raised recently on the list. The
code is done and tested on Windows, but needs to be tested on a POSIX system
before committing to the CVS HEAD.

Thanks for the report,


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