Opened 16 years ago
Closed 16 years ago
#652 closed Bugs (None)
Still assertion failure in boost::format for empty strings
Reported by: | daniel_kruegler | Owned by: | nobody |
---|---|---|---|
Milestone: | Component: | None | |
Version: | None | Severity: | |
Keywords: | Cc: |
Description
The assertion failure of boost::format in case of empty string arguments that occured since VS2005 has been partly fixed by cepstein in March 2006. This fix was partial, because there still exists a corner case, where this assertion can take place: #include <iostream> #include <ostream> #include <string> #include <boost/format.hpp> int main() { std::string arg; // empty string boost::format fmt = boost::format("%=8s") % arg; std::string s = fmt.str(); std::cout << s << std::endl; } The proposed patch looks in unified syntax: Index: feed_args.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/format/feed_args.hpp,v retrieving revision 1.29 diff -u -r1.29 feed_args.hpp --- feed_args.hpp 22 Mar 2006 15:13:25 -0000 1.29 +++ feed_args.hpp 15 Jun 2006 19:49:37 -0000 @@ -63,7 +63,8 @@ if(n_before) res.append(n_before, fill_char); if(prefix_space) res.append(1, prefix_space); - res.append(beg, size); + if (size) + res.append(beg, size); if(n_after) res.append(n_after, fill_char); } } // -mk_str(..) and in standard syntax: Index: feed_args.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/format/feed_args.hpp,v retrieving revision 1.29 diff -r1.29 feed_args.hpp 66c66,67 < res.append(beg, size); --- > if (size) > res.append(beg, size);
Note:
See TracTickets
for help on using tickets.