Modify

Ticket #3729 (closed Bugs: invalid)

Opened 4 years ago

Last modified 4 years ago

boost.log and 1.41.0 : external linkage error

Reported by: lb <lburgazzoli@…> Owned by: igaztanaga
Milestone: Boost 1.42.0 Component: intrusive
Version: Boost 1.41.0 Severity: Problem
Keywords: Cc:

Description

compilation of boost.log ( http://boost-log.sourceforge.net) within boost 1.41 on Mac OSX 10.5 and gcc 4.2.1 fails due to an "external linkage" error:

./boost/intrusive/detail/is_stateful_value_traits.hpp:38: error: ‘& boost::intrusive::derivation_value_traits<T, NodeTraits?, LinkMode?>::to_node_ptr [with T = boost::log_mt_posix::basic_attribute_set<char>::implementation::node, NodeTraits? = boost::log_mt_posix::<unnamed>::ordered_list<boost::log_mt_posix::basic_attribute_set<char>::implementation::node, boost::log_mt_posix::basic_attribute_set<char>::node_base>::node_traits, boost::intrusive::link_mode_type LinkMode? = safe_link]’ is not a valid template argument for type ‘boost::log_mt_posix::basic_attribute_set<char>::node_base* (*)(boost::log_mt_posix::basic_attribute_set<char>::implementation::node&)’ because function ‘static typename NodeTraits::node_ptr boost::intrusive::derivation_value_traits<T, NodeTraits?, LinkMode?>::to_node_ptr(typename std::iterator_traits<typename boost::pointer_to_other<typename NodeTraits::node_ptr, T>::type>::reference) [with T = boost::log_mt_posix::basic_attribute_set<char>::implementation::node, NodeTraits? = boost::log_mt_posix::<unnamed>::ordered_list<boost::log_mt_posix::basic_attribute_set<char>::implementation::node, boost::log_mt_posix::basic_attribute_set<char>::node_base>::node_traits, boost::intrusive::link_mode_type LinkMode? = safe_link]’ has not external linkage

"g++" -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -dynamic -no-cpp-precomp -gdwarf-2 -fPIC -DBOOST_ALL_NO_LIB=1 -DBOOST_DATE_TIME_DYN_LINK=1 -DBOOST_FILESYSTEM_DYN_LINK=1 -DBOOST_LOG_BUILDING_THE_LIB=1 -DBOOST_LOG_DLL -DBOOST_LOG_USE_CHAR -DBOOST_LOG_USE_NATIVE_SYSLOG=1 -DBOOST_SYSTEM_DYN_LINK=1 -DBOOST_THREAD_POSIX -DBOOST_THREAD_USE_DLL=1 -DDATE_TIME_INLINE -DNDEBUG -I"." -c -o "bin.v2/libs/log/build/darwin-4.2.1/release/threading-multi/attribute_set.o" "libs/log/src/attribute_set.cpp"

I had reported the problem to the boost.log maintaner before to open the ticket and the response was:

Looks like a compiler bug to me since the derivation_value_traits::to_value_ptr clearly has external linkage.

You should report the problem to Boost.Intrusive maintainer. 
I'm not sure I can work it around on Boost.Log side.

Attachments

Change History

comment:1 Changed 4 years ago by andysem

  • Status changed from new to closed
  • Resolution set to invalid

From the Boost developers ML:

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.

-- Kim Barrett

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.