Opened 9 years ago
Last modified 9 years ago
#9606 new Bugs
Boost.LocalFunction cannot bind pointer variables by reference on gcc/clang
| Reported by: | Owned by: | Lorenzo Caminiti | |
|---|---|---|---|
| Milestone: | To Be Determined | Component: | local function |
| Version: | Boost Development Trunk | Severity: | Problem |
| Keywords: | Cc: |
Description
Boost.LocalFunction 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 r86799. 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
// Example compile: g++ -I /usr/local/include/boost_1_55_0 -o bug bug.cpp
#include <boost/local_function.hpp>
#include <stdio.h>
int main()
{
int x = 1;
int *px = &x;
void BOOST_LOCAL_FUNCTION(bind& px, bind& x)
{
printf("INSIDE: &px = %p, &x = %p\n", &px, &x);
}
BOOST_LOCAL_FUNCTION_NAME(fubar)
printf("OUTSIDE: &px = %p, &x = %p\n", &px, &x);
fubar();
return 0;
}
The pointer values output by this program should be identical for both the INSIDE and OUTSIDE cases. Notice that value for &px differs.
I found some ways to sort of make this work but none of them are acceptable workarounds for me:
- Binding pointer variables works perfectly in Boost.ScopeExit for all compilers/platforms that I tested
- Adding "-std=c++0x" to the compiler line also fixes the problem
Change History (2)
comment:1 by , 9 years ago
| Component: | None → local function |
|---|---|
| Owner: | set to |
| Version: | Boost 1.54.0 → Boost Development Trunk |
comment:2 by , 9 years ago
Note:
See TracTickets
for help on using tickets.

I reproduced this behavior too