Opened 8 years ago
Closed 5 years ago
#10852 closed Bugs (obsolete)
boost format operator % won't accept dereference of volatile
Reported by: | Owned by: | James E. King, III | |
---|---|---|---|
Milestone: | To Be Determined | Component: | format |
Version: | Boost 1.56.0 | Severity: | Regression |
Keywords: | format volatile | Cc: |
Description
struct A{
A() : a(9) {} int a;
}; A a; A volatile *pva = &a;
std::cout << boost::format("%d") % pva->a << std::endl;
This worked in 1_54 but fails in 1_56 with error:
format/feed_args.hpp:135:47: error: invalid conversion from 'volatile void*' to 'const void*'
Can work around this with cast:
std::cout << boost::format("%d") % (int)pva->a << std::endl;
but should not have to. The appearance to the user is pass by value.
Running linux with g++ 4.6.2 and 4.8.2
Change History (6)
comment:1 by , 8 years ago
comment:2 by , 7 years ago
This is present in boost 1.59 using clang-3.8 (in development) as well. It happens with any numeric type, not just int. One workaround is to use a static_cast to the same type, stripping the volatile keyword.
comment:3 by , 6 years ago
I ran into the same issue in boost 1.61.0 using visual studio 2008 (msvc-9.0), with a volatile size_t. static_cast<size_t> is the current workaround i'm using.
comment:5 by , 5 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:6 by , 5 years ago
Resolution: | → obsolete |
---|---|
Status: | assigned → closed |
Issue moved to github: https://github.com/boostorg/format/issues/36
We recently run into the very same problem: Our logger internally delegates to boost::format and users complained that they cannot logging output for volatile variables.