Boost C++ Libraries: Ticket #8298: Clang error with Boost Phoenix Local Name Assignment using C++11 https://svn.boost.org/trac10/ticket/8298 <p> 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 <strong>-std=c++11</strong> flag is used. </p> <p> 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. </p> <div class="wiki-code"><div class="code"><pre><span class="cp">#include</span> <span class="cpf">&lt;iostream&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/phoenix.hpp&gt;</span><span class="cp"></span> <span class="k">namespace</span> <span class="n">phoenix</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">phoenix</span><span class="p">;</span> <span class="k">using</span> <span class="k">namespace</span> <span class="n">phoenix</span><span class="o">::</span><span class="n">local_names</span><span class="p">;</span> <span class="kt">int</span> <span class="nf">main</span><span class="p">(</span><span class="kt">int</span> <span class="n">argc</span><span class="p">,</span> <span class="kt">char</span> <span class="o">*</span><span class="n">argv</span><span class="p">[])</span> <span class="p">{</span> <span class="n">phoenix</span><span class="o">::</span><span class="n">lambda</span><span class="p">(</span><span class="n">_a</span><span class="o">=</span><span class="mi">17</span><span class="p">)[</span> <span class="n">_a</span> <span class="o">=</span> <span class="mi">18</span><span class="p">,</span> <span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o">&lt;&lt;</span> <span class="n">_a</span> <span class="o">&lt;&lt;</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span> <span class="p">]()();</span> <span class="k">return</span> <span class="mi">0</span><span class="p">;</span> <span class="p">}</span> </pre></div></div> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8298 Trac 1.4.3 Paul Keir <pkeir@…> Sat, 16 Mar 2013 21:50:30 GMT attachment set https://svn.boost.org/trac10/ticket/8298 https://svn.boost.org/trac10/ticket/8298 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">phx_bug.cpp</span> </li> </ul> Ticket Paul Keir <pkeir@…> Sat, 16 Mar 2013 21:54:15 GMT <link>https://svn.boost.org/trac10/ticket/8298#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8298#comment:1</guid> <description> <p> The error begins: </p> <p> <strong>error: read-only variable is not assignable</strong> <strong> BOOST_PROTO_BINARY_DEFAULT_EVAL(=, assign, make_mutable, make)</strong> </p> <p> I also found that the assignment to Phoenix local variable <strong>_a</strong> is required for the error to occur. </p> </description> <category>Ticket</category> </item> <item> <author>John Fletcher <J.P.Fletcher@…></author> <pubDate>Fri, 07 Feb 2014 22:34:24 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/8298 https://svn.boost.org/trac10/ticket/8298 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">n8298.cpp</span> </li> </ul> <p> Working examples for bug report <a class="new ticket" href="https://svn.boost.org/trac10/ticket/8298" title="#8298: Bugs: Clang error with Boost Phoenix Local Name Assignment using C++11 (new)">#8298</a> </p> Ticket John Fletcher <J.P.Fletcher@…> Fri, 07 Feb 2014 22:37:47 GMT <link>https://svn.boost.org/trac10/ticket/8298#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8298#comment:2</guid> <description> <p> 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 </p> </description> <category>Ticket</category> </item> </channel> </rss>