Opened 8 years ago

Closed 5 years ago

#10852 closed Bugs (obsolete)

boost format operator % won't accept dereference of volatile

Reported by: paul.d.rose@… 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 Daniel Krügler <daniel.kruegler@…>, 8 years ago

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.

comment:2 by jim.king@…, 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 fgeorge@…, 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:4 by arnaud.richard@…, 6 years ago

Same issue in boost 1.63.0 using Linaro GCC 5.2-2015.11-2

comment:5 by James E. King, III, 5 years ago

Owner: changed from Samuel Krempp to James E. King, III
Status: newassigned

comment:6 by James E. King, III, 5 years ago

Resolution: obsolete
Status: assignedclosed
Note: See TracTickets for help on using tickets.