Opened 16 years ago
Closed 16 years ago
#678 closed Bugs (None)
bug in boost:format
| Reported by: | andreims | Owned by: | Douglas Gregor |
|---|---|---|---|
| Milestone: | Component: | function | |
| Version: | None | Severity: | |
| Keywords: | Cc: |
Description
Hello,
software configuration:
boost 1.33.1
stlport 5.0
example:
std::string ret = boost::str(boost::format("%1%") %
std::string(""));
If you try to send as first argument the empty string
to %-operator then you catch assertion failure in stl
code:
STLport-5.0.0\stlport\stl/debug/_string.h(308): STL
error : Invalid argument to operation (see operation
documentation)
STLport-5.0.0\stlport\stl/debug/_string.h(308): STL
assertion failure: (__s != 0)
The null-pointer argument is passed from this:
boost/boost/format/feed_args.hpp
namespace boost {
namespace io {
namespace detail {
template<class Ch, class Tr, class Alloc>
void mk_str( std::basic_string<Ch,Tr, Alloc> &
res,
const Ch * beg,
typename
std::basic_string<Ch,Tr,Alloc>::size_type size,
std::streamsize w,
const Ch fill_char,
std::ios_base::fmtflags f,
const Ch prefix_space, // 0 if no
space-padding
bool center)
// applies centered/left/right padding to the
string [beg, beg+size[
// Effects : the result is placed in res.
{
typedef typename
std::basic_string<Ch,Tr,Alloc>::size_type size_type;
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); /// here "beg" is
null
}
...
////////////////////--------------------------
There is no assertion failure if you pass empty string
as second argument,
e.g.
std::string ret = boost::str(boost::format("%1% %2%")
% 2 % std::string(""));
Best regards,
Andrei Selikhanovich
Note:
See TracTickets
for help on using tickets.
