Opened 9 years ago

Closed 4 years ago

#9363 closed Bugs (fixed)

Reference forwarding in phoenix::bind does not work in C++11

Reported by: Andrey Semashev Owned by: Thomas Heller
Milestone: To Be Determined Component: phoenix
Version: Boost 1.55.0 Severity: Problem
Keywords: Cc:

Description

When a user-defined function accepts a non-const reference as an argument, this argument is provided as a const reference by phoenix::bind, even though phoenix::bind is invoked with a non-const lvalue. This only appears in C++11 mode, in C++03 this works as expected.

I've attached the test case and compile errors from GCC 4.8.1.

Attachments (2)

phoenix_non_const_ref.cpp (338 bytes ) - added by Andrey Semashev 9 years ago.
A test case to reproduce the problem.
phoenix_non_const_ref_cxx11.txt (19.2 KB ) - added by Andrey Semashev 9 years ago.
GCC 4.8.1 errors in C++11 mode.

Download all attachments as: .zip

Change History (5)

by Andrey Semashev, 9 years ago

Attachment: phoenix_non_const_ref.cpp added

A test case to reproduce the problem.

by Andrey Semashev, 9 years ago

GCC 4.8.1 errors in C++11 mode.

comment:1 by Andrey Semashev, 9 years ago

I might add that this bug affects Boost.Log in a very bad way. It breaks binding user-defined functions as formatters because the output stream is passed to the bound functions by const reference.

comment:2 by John Fletcher <J.P.Fletcher@…>, 9 years ago

I have started to look at this but have not got very far with this yet. I will keep it on my list. John

comment:3 by Andrey Semashev, 4 years ago

Resolution: fixed
Status: newclosed

The test case compiles with gcc 8.2 with Boost 1.68.

Note: See TracTickets for help on using tickets.