
On 01/29/2010 08:05 PM, Kim Barrett wrote:
The combination of gcc version (gcc 4.2.x), the reported error reason (has not external linkage) and the type in the error location including names in an anonymous namespace (occurrences of<unnamed>) lead me to believe this is the same as a problem I've encountered a number of times, most recently yesterday.
The issue seems to be that gcc 4.2 contains (the beginnings of?) an optimization to exclude symbols from anonymous namespaces from the set of external linker symbols, as a space optimization, and possibly with other benefits. Unfortunately, in gcc 4.2 this seems to have been somewhat botched because these symbols still need to be treated as having external linkage as far as various C++ language features are concerned, and that doesn't appear to be done correctly. These problems seem to have been addressed in gcc 4.3.
The only workaround I've found for this is to change the relevant anonymous namespace to be a named namespace, typically some "detail" or "impl" type of namespace since these aren't supposed to be public names. I've only encountered this problem with gcc 4.2.x; 4.1 doesn't have the (attempt at) the relevant optimization, and this problem seems to have been fixed in gcc 4.3.
Thanks for the insight. This issue has already been reported to me but I thought this was a compiler bug triggered by Boost.Intrusive. It all ended in the trac ticket #3729. I will add a workaround to Boost.Log.