New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boost format operator % won't accept dereference of volatile #36

Closed
jeking3 opened this Issue Oct 18, 2017 · 1 comment

Comments

Projects
None yet
1 participant
@jeking3
Collaborator

jeking3 commented Oct 18, 2017

Originally reported by Paul Rose in Boost Trac.

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

Originally reported in Boost 1.56.0.
Confirmed in Boost 1.59.0 with clang-3.8 on linux.
Confirmed in Boost 1.61.0 with VS2008.
Confirmed in Boost 1.63.0 with gcc-5.2.

@jeking3 jeking3 added the bug label Oct 18, 2017

jeking3 added a commit to jeking3/format that referenced this issue Oct 25, 2017

@jeking3

This comment has been minimized.

Show comment
Hide comment
@jeking3

jeking3 Oct 25, 2017

Collaborator

My solution in the pull request is to make a copy of the argument being passed in; by making a copy of it we force it to be read, and the copy is not volatile, then we pass the copy on through format's normal machinery.

Collaborator

jeking3 commented Oct 25, 2017

My solution in the pull request is to make a copy of the argument being passed in; by making a copy of it we force it to be read, and the copy is not volatile, then we pass the copy on through format's normal machinery.

jeking3 added a commit to jeking3/format that referenced this issue Oct 25, 2017

@jeking3 jeking3 closed this in #48 Oct 26, 2017

jeking3 added a commit that referenced this issue Oct 26, 2017

handle volatile arguments to operator% by making a non-volatile
copy of them before feeding through

This fixes #36

@jeking3 jeking3 self-assigned this Dec 18, 2017

@jeking3 jeking3 added this to the v1.66.0 milestone Dec 18, 2017

jeking3 pushed a commit to jeking3/format that referenced this issue Jun 17, 2018

Merge pull request boostorg#36 from jurko-gospodnetic/fix-example-fol…
…der-path-in-docs

correct example folder path in docs from `examples/` to `example/`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment