Git Product home page Git Product logo

Comments (3)

Kojoley avatar Kojoley commented on August 26, 2024

This is https://svn.boost.org/trac10/ticket/8298.

@fletchjp said there:

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.

from phoenix.

Kojoley avatar Kojoley commented on August 26, 2024

I investigated this and found multiple bugs.

  1. The let documentation states that _a should has int type, but for C++11 it is int const& because of tr1/decltype result_of differences https://wandbox.org/permlink/27AcBJnXskKPl9uU. If you define BOOST_RESULT_OF_USE_TR1 the example will compile run https://wandbox.org/permlink/Daf4VxdLyETDRs8p.

  2. Internally Phoenix places locals into a vector and than operates on it through const reference, so actually it cannot modify it and passes _a as int const&, but mutual operators were working because int const& was casted to int& here

    return RT(fusion::at_c<Index>(env.locals));

  3. The other bug is that let(_a = 0)[_a]() returns a reference to temporary (with BOOST_RESULT_OF_USE_TR1 even non-const!).

It looks like a disaster, users can use those references to temporaries and do not know this. I have some thoughts about this:

  1. I think that let(_a = 0)[--_a]() should work.
  2. The return type of it (and let(_a = 0)[_a]()) must be a value.
  3. Making things above will require to distinguish between temporaries and references. With C++11 it is not a problem (rvalues will be stored as value types), but for C++98 let will start copying const references values (it can be avoided by users with ref; non-const values will work fine).

from phoenix.

fletchjp avatar fletchjp commented on August 26, 2024

from phoenix.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.