Subject: [Boost-bugs] [Boost C++ Libraries] #9102: Various Boost header files define variables with internal linkage, which results in unnecessary code bloat
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-09-11 09:39:06
#9102: Various Boost header files define variables with internal linkage, which
results in unnecessary code bloat
-------------------------------+------------------------------
Reporter: abacabadabacaba@⦠| Type: Bugs
Status: new | Milestone: To Be Determined
Component: None | Version: Boost 1.54.0
Severity: Optimization | Keywords:
-------------------------------+------------------------------
Some Boost headers define variables with internal linkage. For example, in
`boost/system/error_code.hpp`:
{{{
static const error_category & posix_category = generic_category();
static const error_category & errno_ecat = generic_category();
static const error_category & native_ecat = system_category();
}}}
In `boost/asio/error.hpp`:
{{{
static const boost::system::error_category& system_category
= boost::asio::error::get_system_category();
static const boost::system::error_category& netdb_category
= boost::asio::error::get_netdb_category();
static const boost::system::error_category& addrinfo_category
= boost::asio::error::get_addrinfo_category();
static const boost::system::error_category& misc_category
= boost::asio::error::get_misc_category();
}}}
Because of this, every translation unit that includes these headers
results in a separate instance of each of these variables in the resulting
executable file. Because these variables have non-constant initializers,
not only they are not eliminated during linking, even if not used, but
also each instance of such variable results in a call to a initialization
function during program startup.
I think that merely including a Boost header, without using anything from
it, should not result in any extra code remaining in the resulting
executable - especially not if each translation unit results in a separate
copy of such code.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/9102> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:14 UTC