Opened 13 years ago

Closed 11 years ago

#627 closed Bugs (fixed)

program_options: format_paragraph assert fails on long line

Reported by: kbluck Owned by: Vladimir Prus
Milestone: Component: None
Version: None Severity: Showstopper
Keywords: Cc:


Boost 1.33.1, MSVC 8.0

When format_paragraph() in options_description.cpp
attempts to format a line that will wrap because it is
> 80 chars, it causes an assert failure in the standard
library string iterator's operator+=(). The offending
po:: code line is options_description.cpp Line 361:

if (line_begin + (line_length - indent) > par_end)

Relevant call stack attached.

My guess is that the assert is complaining that the +
operation has produced an iterator past the string's
end(); this code seems to be assuming that the iterator
object is a pointer. I believe it is officially
undefined to advance an iterator past end().

One way of getting around this might be to use
std::distance instead of comparing the iterators directly.

Change History (5)

comment:1 Changed 13 years ago by Vladimir Prus

Logged In: YES 

Thank you for the bug report. However, I believe this bug  
is already fixed in the CVS, and the bugfix will be 
included in the 1.34 release.  

comment:2 Changed 13 years ago by kbluck

Status: assignedclosed
Logged In: YES 

Thanks for the quick response; I should have checked CVS in
the first place.

I just now rebuilt with options_description.cpp HEAD, file
rev. 1.16. The same assertion is still there, although the
triggering po:: code has now moved to line 375:

line_end = line_begin + line_length;

I'm pretty sure it's the same issue: the string's iterator
is being incremented past end().

I've updated the call stack attachment to reflect the
current line numbes.

comment:3 Changed 13 years ago by az_sw_dude

Logged In: YES 

Assign to Vladimir

comment:4 Changed 12 years ago by Vladimir Prus

Logged In: YES 
Originator: NO

Would you please try again. Revision 1.17 of options_description.cpp (and on RC_1_34_0 branch) have some possible fixes.

comment:5 Changed 11 years ago by Vladimir Prus

Resolution: Acceptedfixed
Severity: Showstopper
Status: assignedclosed

No further feedback from submitter, so I assume this is fixed in revision 1.17.

Note: See TracTickets for help on using tickets.