[assert] [exception] Fast output binary file size growth

Greetings, When BOOST_ENABLE_ASSERT_HANDLER is defined or BOOST_THROW_EXCEPTION used, compiler generates a string with function name. If a function is templated, compiler will generate a string for each function template. That leads to a huge binary files. Consider the following example: #define BOOST_ENABLE_ASSERT_HANDLER #include <boost/assert.hpp> template <class MplVectorT> void do_something(bool v) { BOOST_ASSERT(v); } void do_something<boost::mpl::vector<int, double>>(v); void do_something<boost::mpl::vector<int, int>>(v); This two functions will generate strings like "void do_something<MplVectorT>(bool v) [with MplVectorT = boost::mpl::vector<int, double> ]" and "void do_something<MplVectorT>(bool v) [with MplVectorT = boost::mpl::vector<int, int> ]". When there is more mataprogramming, one such string can have a size of a few kilobytes. In one of my binaries, such strings take more than 50 megabytes of binary size (total size of binary is 70 megabytes). I`ve got a patch and documentation update for Boost.Assert and Boost.Exception, that allow to disable construction of such strings or to use different macro for current function name (for example macro that prints ONLY function name). Is there interest in this feature/patches? Best regards, Antony Polukhin

On Wed, Jan 25, 2012 at 9:10 AM, Antony Polukhin <antoshkka@gmail.com> wrote:
Greetings,
When BOOST_ENABLE_ASSERT_HANDLER is defined or BOOST_THROW_EXCEPTION used, compiler generates a string with function name.
If a function is templated, compiler will generate a string for each function template. That leads to a huge binary files.
I'm interested to see your patch, but in general you don't need to throw from meta-generated function templates, you could move the throw in a separate function. Emil Dotchevski Reverge Studios, Inc. http://www.revergestudios.com/reblog/index.php?n=ReCode

2012/1/26 Emil Dotchevski <emildotchevski@gmail.com>:
I'm interested to see your patch, but in general you don't need to throw from meta-generated function templates, you could move the throw in a separate function.
Created tickets #6450 (Boost.Exception), #6451 (Boost.Assert). Best regards, Antony Polukhin
participants (2)
-
Antony Polukhin
-
Emil Dotchevski