On 11/28/05, Mick Hollins <mick@hollins.id.au> wrote:yes I agree.The following code causes a runtime assertion in VC 8.0:
std::string l_param;
std::string l_str = (boost::format("here is an empty string: %1%") % l_param).str();
It passes an empty string argument to boost::format.
The assert is inside the implementation of basic_string::append()
and boils down to the fact that the implementation of boost::format ends up calling
basic_string::append(const char *, size_type) with a null pointer, which causes
basic_string::append to assert.
This assertion seems to only happen with /MDd (e.g. debug runtime), but I'd say it qualifies as a bug in Boost.Format.
Yep that seems like the obvious fix. I've not yet been involved in contributing to boost, but am happy to do so, so I'm gonna read up on exactly how one goes about getting a change into the base and go from there. I presume there's doco somewhere on the boost site that tells me how to get started ...I think the simple and obvious fix is to just check for size != 0 before calling res.append, but I'm not familiar with this code.typedef typename std::basic_string<Ch,Tr,Alloc>::size_type size_type;
And here's the offending code from boost::io::detail::mk_str (feed_args.hpp):
res.resize(0);
if(w<=0 || static_cast<size_type>(w) <=size) {
// no need to pad.
res.reserve(size + !!prefix_space);
if(prefix_space)
res.append(1, prefix_space);
=> res.append(beg, size);
}