Boost logo

Boost Users :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2007-02-24 03:13:06


Torrey Pines wrote:

> Hi
>
> I fooled around with the debugger a little, and it looks like
> program_options decrements a string iterator that already points at
> the beginning of a string.
>
> string::const_iterator last_space =
> find(reverse_iterator<string::const_iterator>(line_end - 1),
> reverse_iterator<string::const_iterator>(line_begin - 1), '
> ').base();
>
> I'm assuming that this is the error

It is.

> (I haven't had a chance to look at
> CVS yet). I'm no language lawyer, but I would think that such behavior
> is undefined. Why is it unreasonable for VC++2005 to test for it?

Because the before the beginning iterator is never dereferenced, and for
string, it's quite possible to decrement iterators any way you like.
Checking done by VC++2005 might be ok from language lawyer point of view,
but I don't see any real error that would prevent.

> I'm not an expert Boost user, and I need a stable version. Should I
> just change (line - 1) to (line)+1 ?

I attach two patches that were committed to CVS to fix this problem.
You might want to try to apply them manually to the version
of options_description.cpp that you have.

- Volodya





Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net