Opened 13 years ago

Closed 13 years ago

#3610 closed Bugs (fixed)

boost::format copy constructor can create format object in unexpected state.

Reported by: David Ward <davidjward30@…> Owned by: Samuel Krempp
Milestone: Boost 1.41.0 Component: format
Version: Boost 1.37.0 Severity: Problem
Keywords: Cc:

Description

If I copy construct a new boost::format object, I expect it to be in a (re)useable state. However, the following code throws a boost::io::too_many_args exception

{

boost::format f("%d");

std::cout << f % 10 << std::endl; std::cout << f % 10 << std::endl; format object can be reused

boost::format f2(f); std::cout << f2 % 10 << std::endl; exception raised - new format is not in a valid state for formatting

}

On inspection of the code, the copy constructor always sets the dumped_ member to false, yet it copies the cur_arg_ from the rhs object. It's hard to see how this behaviour might be desirable.

Change History (1)

comment:1 by Samuel Krempp, 13 years ago

Resolution: fixed
Status: newclosed

Agreed, that was an oversight, the copy-constructed should copy .dumped_ fixed in revision 57672

Note: See TracTickets for help on using tickets.