Opened 16 years ago

Closed 15 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:

Description

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 by Vladimir Prus, 16 years ago

Logged In: YES 
user_id=321498

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 by kbluck, 16 years ago

Status: assignedclosed
Logged In: YES 
user_id=11142

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 by az_sw_dude, 16 years ago

Logged In: YES 
user_id=579686

Assign to Vladimir

comment:4 by Vladimir Prus, 16 years ago

Logged In: YES 
user_id=321498
Originator: NO

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

comment:5 by Vladimir Prus, 15 years ago

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.