- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Using boost::function with functors defined in local namespaces of TUs is currently broken if the functor is a class that has the same name in multiple TUs, because boost::function uses static locals in its implementations. We were able to reduce the problem to the following testcase
a1.cc:
template<typename T>
int f(T) { static int x = T::x; return x; }
namespace { struct A { static const int x = 1; }; }
int f1() {
return f(A());
}
a2.cc:
template<typename T>
int f(T) { static int x = T::x; return x; }
namespace { struct A { static const int x = 0; }; }
int f2() {
return f(A());
}
main.cc:
#include <cstdio>
int f1();
int f2();
int main() {
std::printf("%d != %d\n", f1(), f2());
}
Command line:
# icpc a1.cc a2.cc main.cc -o main
# ./main
0 != 0
When inspecting the produced symbols with readelf, we noted that while `f` is has local linkage, as we think it should have, the `x` static variable receives weak linkage and gets the same mangled name and therefore the two `x`'es are merged and it becomes lottery which is chosen.
# icpc a2.cc a1.cc main.cc -o main
# ./main
1 != 1
GCC compiles this and produces the expected output. I also asked on Stackoverflow about it, see http://stackoverflow.com/questions/33262590/are-static-locals-of-function-template-specializations-with-t-unnamed-namespace
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We have DPD200377293 tracking this issue in our internal bugs database. Thanks for reporting it, and thanks for the test case. --Melanie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Melanie, I've updated this thread with the issue number so we can monitor and let @Zes know as well.
@Zes, Yes, this issue is being investigated and I'll keep you updated as soon as the release with the fix is out most probably at the end of this quarter (Melanie can correct me otherwise), appreciate much.
_Kittur
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Zes: Unfortunately, the code cut off has taken place for update 1 and therefore the fix will end up in a subsequent release to the next update :-( I'll keep you updated accordingly and again, appreciate your patience.
_Kittur
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Zes:
Hi,
Just letting you know that this issue is fixed in the latest 16.0 update 2 release which you can download and test it out. Thanks for bringing this issue to our attention and patience through this issue as well.
_Kittur

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page