Opened 10 years ago
Last modified 9 years ago
#8298 new Bugs
Clang error with Boost Phoenix Local Name Assignment using C++11
Reported by: | Owned by: | Thomas Heller | |
---|---|---|---|
Milestone: | To Be Determined | Component: | phoenix |
Version: | Boost Development Trunk | Severity: | Problem |
Keywords: | Cc: |
Description
The attached minimal main file (also shown below) will fail to compile with Clang++ version 3.2 under 64-bit Ubuntu, and also Arch Linux. It will however only fail when the -std=c++11 flag is used.
I noticed that the default Boost version on Ubuntu (1.49.0) did not give the error, so I tried Boost 1.53.0, 1.52.0 and also boost-trunk from svn, all of which give the same error. Boost 1.51.0 does not give the error.
#include <iostream> #include <boost/phoenix.hpp> namespace phoenix = boost::phoenix; using namespace phoenix::local_names; int main(int argc, char *argv[]) { phoenix::lambda(_a=17)[ _a = 18, std::cout << _a << std::endl ]()(); return 0; }
Attachments (2)
Change History (4)
by , 10 years ago
Attachment: | phx_bug.cpp added |
---|
comment:1 by , 10 years ago
comment:2 by , 9 years ago
The bug here is that this ever worked. The local variables _a do not provide a true variable. This means that _a = 17 followed by _a = 18 amounts to 17 = 18 i.e. assigning to a constant. The attached file n8298.cpp shows two ways to do it validly by providing a variable, and also uses the return value from the lambda to export a value. John Fletcher
The error begins:
error: read-only variable is not assignable BOOST_PROTO_BINARY_DEFAULT_EVAL(=, assign, make_mutable, make)
I also found that the assignment to Phoenix local variable _a is required for the error to occur.