[Boost-bugs] [Boost C++ Libraries] #2024: boost::format("%p") % (uint8_t *) str is not like printf("%p", str)

Subject: [Boost-bugs] [Boost C++ Libraries] #2024: boost::format("%p") % (uint8_t *) str is not like printf("%p", str)
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2008-06-19 15:24:34


#2024: boost::format("%p") % (uint8_t *) str is not like printf("%p", str)
---------------------------------------------------+------------------------
 Reporter: Geoff Barrett <gbarrett_at_[hidden]> | Owner: samuel_krempp
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: format
  Version: Boost 1.34.0 | Severity: Problem
 Keywords: |
---------------------------------------------------+------------------------
 I'm actually on 1.33.1 still but I can't see any difference that fixes
 this in the latest code.

 The boost::format gets pointers to 8-bit types wrong. This because the
 underlying type is indistinguishable from a string. In this case, I think
 the formatting needs to take the hint from the format string about how to
 interpret the type.

 I have a fix which is slightly hacky. Instead of passing the printf
 parameter directly to %, it can be wrapped in a container whose insertion
 method inspects the stream flags to see whether any of the basefield bits
 are set and only prints like a char/string if none of them are. The
 wrapper type is in the attachment. The format parsing needs to clear the
 basefield bits. Here is the diff from format/parsing.hpp:

 321d320
 < fpar->fmtstate_.flags_ &= ~std::ios_base::basefield;
 326d324
 < fpar->fmtstate_.flags_ &= ~std::ios_base::basefield;

--
Ticket URL: <http://svn.boost.org/trac/boost/ticket/2024>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.


This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:58 UTC