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: Paul Keir <pkeir@…> 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)

phx_bug.cpp (584 bytes ) - added by Paul Keir <pkeir@…> 10 years ago.
n8298.cpp (825 bytes ) - added by John Fletcher <J.P.Fletcher@…> 9 years ago.
Working examples for bug report #8298

Download all attachments as: .zip

Change History (4)

by Paul Keir <pkeir@…>, 10 years ago

Attachment: phx_bug.cpp added

comment:1 by Paul Keir <pkeir@…>, 10 years ago

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.

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

Attachment: n8298.cpp added

Working examples for bug report #8298

comment:2 by John Fletcher <J.P.Fletcher@…>, 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

Note: See TracTickets for help on using tickets.