Re: [boost] boost::format - incorrect (printf-incompatible) handling of "%u" with characters

Zack wrote:
Consider the following example program:
#include <boost/format.hpp> #include <cstdio> #include <string>
int main() { unsigned char n = 65; std::printf("%u\n", n); std::puts((boost::format("%u") % n).str().c_str()); }
$ g++ test.cc $ ./a.out 65 A
In my opinion this is a bug - both operations should produce "65".
See my previous report: http://thread.gmane.org/gmane.comp.lib.boost.user/23644 which continues at http://thread.gmane.org/gmane.comp.lib.boost.user/23664 The conclusion at that time was that - you can just cast to an int if this is what you want. - you shouldn't be using bytes to store numbers - that's unnecessary size optimisation. I didn't agree with those conclusions, and I'm no longer using boost::format. Phil.
participants (1)
-
Phil Endecott