C++ Logo

std-proposals

Advanced search

Re: [std-proposals] template catch block

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Sat, 23 Sep 2023 23:37:26 +0100
On Sat, Sep 23, 2023 at 10:04 PM Thiago Macieira wrote:
>
> The source code for Chromium is readily available on the Internet. It's not at
> all easy to build (you need Node.js to generate the build files), but it's
> doable and lots of people do it every day.
>
> Anyway, if after the feedback you've already received you still think this is
> an idea worth pursuing, I suggest you implement it in one of the compilers and
> see if it can be done with
> a) reasonable amount of memory for the compiler
> b) reasonable time spent compiling
> c) non-explosive code expansion in the resulting binaries


The biggest program I've ever written, which I started writing about
14 years ago, is now 41 object files. It's linked with Boost and
wxWidgets. On Linux, I can get all the typeinfo's at the command line
as follows:

    nm -C *.o | grep "typeinfo for" | grep -v " U " | cut -d ' ' -f 5-

This comes back with lines like:

    Source_Of_Network_Data
    Source_Of_Network_Data____Chameleon
    Source_Of_Network_Data____File_pcap
    Source_Of_Network_Data____NetworkCard
    std::bad_optional_access
    std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >
    std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >*
    std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> > const*
    std::__cxx11::sub_match<char const*>
    std::__cxx11::sub_match<char const*>*
    std::__cxx11::sub_match<char const*> const*
    std::__cxx1998::_Base_bitset<4ul>
    std::__cxx1998::bitset<256ul>

In total, for all 41 object files, it comes back with 219 typeinfo's.
I can take all of those types and make a translation unit for each of
them, containing just:

    #include "header_containing_class_definition.hpp"

    void Func(Type &obj)
    {
        // do stuff in here
    }

Some of these translation units will compile, and some of them won't.
For those that successfully compile, I'll use objdump to extract the
machine code, and then I'll look for identical implementations, so the
219 typeinfo's might whittle down to something like 150. If each
implementation doesn't come to more than a few kilobytes, then all of
them combined should be less than a megabyte.

Received on 2023-09-23 22:37:39