Boost C++ Libraries: Ticket #9606: Boost.LocalFunction cannot bind pointer variables by reference on gcc/clang https://svn.boost.org/trac10/ticket/9606 <p> Boost.<a class="missing wiki">LocalFunction</a> cannot bind pointer variables by reference on gcc or clang. I have tested this against the latest boost code available in version 1.55.0 and <a class="changeset" href="https://svn.boost.org/trac10/changeset/86799" title="trac 9280: moved handling of deferred events to history policy">r86799</a>. I have tested that it works on Visual Studio though but not on gcc 4.1 (Linux), 4.6 (Linux), nor clang 5.0 (OSX). Here's the test </p> <pre class="wiki">// Example compile: g++ -I /usr/local/include/boost_1_55_0 -o bug bug.cpp #include &lt;boost/local_function.hpp&gt; #include &lt;stdio.h&gt; int main() { int x = 1; int *px = &amp;x; void BOOST_LOCAL_FUNCTION(bind&amp; px, bind&amp; x) { printf("INSIDE: &amp;px = %p, &amp;x = %p\n", &amp;px, &amp;x); } BOOST_LOCAL_FUNCTION_NAME(fubar) printf("OUTSIDE: &amp;px = %p, &amp;x = %p\n", &amp;px, &amp;x); fubar(); return 0; } </pre><p> The pointer values output by this program should be identical for both the INSIDE and OUTSIDE cases. Notice that value for &amp;px differs. </p> <p> I found some ways to sort of make this work but none of them are acceptable workarounds for me: </p> <ul><li>Binding pointer variables works perfectly in Boost.<a class="missing wiki">ScopeExit</a> for all compilers/platforms that I tested </li><li>Adding "-std=c++0x" to the compiler line also fixes the problem </li></ul> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/9606 Trac 1.4.3 e4lam@… Sat, 25 Jan 2014 16:49:22 GMT version, component changed; owner set https://svn.boost.org/trac10/ticket/9606#comment:1 https://svn.boost.org/trac10/ticket/9606#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">Lorenzo Caminiti</span> </li> <li><strong>version</strong> <span class="trac-field-old">Boost 1.54.0</span> → <span class="trac-field-new">Boost Development Trunk</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">local function</span> </li> </ul> Ticket anonymous Fri, 07 Mar 2014 16:05:33 GMT <link>https://svn.boost.org/trac10/ticket/9606#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9606#comment:2</guid> <description> <p> I reproduced this behavior too </p> </description> <category>Ticket</category> </item> </channel> </rss>