po::options_description desc("supported options");
desc.add_options()
("help,h", "display this help message,this help will be printed out if you not provide option here!");
std::cout << desc << "\n";
}
I have trace this issue, it is located in function format_paragraph in the file options_description.cpp,
namespace {
void format_paragraph(std::ostream& os,
std::string par,
unsigned first_column_width,
unsigned line_length)
{
......
// prevent chopped words
// if (lastchar != ' ') &&
// ((exists(lastchar + 1) && (lastchar + 1 != ' '))
if ((*(line_end - 1) != ' ') &&
((line_end < par_end) && (*line_end != ' ')))
{
// find last ' ' in the second half of the current paragraph line
string::const_iterator last_space =
find(reverse_iterator<string::const_iterator>(line_end - 1),
reverse_iterator<string::const_iterator>(line_begin - 1),
' ')
.base();
if (last_space != line_begin - 1)
{
......
}
if option description is long enough, the find function will be called, and "reverse_iterator<string::const_iterator>(line_begin - 1)" will lead to this issue, may "line_begin - 1" access a invalid space.
If there have some guys to confirm it was a bug in boost?