This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[libstdc++] New implementation of concept checking



This patch replaces the "old" STL concept checking with the new cooler
implementation from Boost.

   [To those of you in the studio audience who are wondering "what the
    heck is Boost and what makes their code any good?" I can only say
    that you should have read the leaflets posted in the lobby as you
    came in.  Ahem.  Very briefly:

      - Boost is www.boost.org
      - They collect free(beer) and free(speech) C++ libraries, which
        undergo a peer review before acceptance.  Many of the peers
        involved are Committee members and other experts of the C++
        community, although anyone can participate.
      - It is generally expected that many future additions to the standard
        library will be shepherded through them.

    Boost member Jeremy Siek, the author of the checker implementation,
    has most graciously agreed to let us steal^H^H^H^H^Hleverage his code.
    I plan to track changes to his library and merge them in with ours. ]


This implementation is considerably cleaner and easier to use than the
previous one.  We'll be feeding everything through a new concept_check.h,
which will include the "real" boost_concept_check.h and create some wrapping
macros.  If the checks are disabled it all goes away.  (I've enabled them
by default, but keep reading.)

If you see any files ending in ...concept_check.h, that's new.
If you see concept_checks.h, with an 's', that's the old SGI code.
                        ^

Important notes about this patch:

1)  The size of programs using checking does increase, but not as much
as with the old implementation, as far as I can tell.  Here are the file
sizes of some of the shared and static testsuite binaries:

        144758 vector_modifiers.sh-exe.OFF*
        194152 vector_modifiers.sh-exe.ON*
       2970061 vector_modifiers.st-exe.OFF*
       3019439 vector_modifiers.st-exe.ON*

        144058 headers.sh-exe.OFF*
        147742 headers.sh-exe.ON*
       3112274 headers.st-exe.OFF*
       3115958 headers.st-exe.ON*

It Would Be Cool if we could tell the compiler, "oh, after instantiating
this symbol, don't bother emitting it at all, not even as a weak symbol,"
which would give us zero space cost as well as zero runtime cost.  Heh.

2)  Since large chunks of libstdc++ are built -fno-implicit-templates,
the instantiations resulting from the typedefs become unresolved symbols
during final executable linking.  Bad.  To avoid this, we disable the
checks while the .a/.so is actually being built.  So, the installed
libraries do not grow in size due to this patch.

3)  You can disable the checks with some specific macros (see
concept_check.h for more), but defining NDEBUG will also turn off these
checks altogether.  Since a lot of projects use NDEBUG for production
builds to kill assert(), we'll do the same.

4)  No new build failures in the testsuite.  The checks pointed out a
couple of small problems, which I fixed, and cause /more/ errrors on
the two files currently XFAILing.  (Side note:  Does map<int, const
int> violate the requirement that the second parameter is supposed to
be assignable?)


Not-So-Important notes about this patch:

1)  I also did a lot of reformatting; SGI had some annoying habits
regarding opening braces of a function.

2)  I killed off some more macros that only get defined to one thing
ever: __ITERATOR_CATEGORY, __DISTANCE_TYPE, __VALUE_TYPE.  Also, there
was some conditional code based on a __USLC__ macro, which I've enver
heard of and can find nowhere else in the entire gcc/binutils tree.

3)  stl_iterator_base.h is split in half.  Basicially, concatenating
stl_iterator_base_types.h and stl_iterator_base_funcs.h will give you the
original header.  The reason is that the checking code needs some of the
type declarations (first half), but the checkers themselves are used in
the functions in the second half.  I split the headers for cleanliness
rather than play games with #include placement.  Other headers changed
to reflect this.

4)  Documentation updated.  Also changed the mailto links at the bottom
of the pages while I was at it.

5)  Testsuite time with checks on:   639 seconds.
    Testsuite time with checks off:  572 seconds.


The new implementaion also offers some new concepts, some different
checks, and a whole bunch of "covering" checks and "archetypes" that
were not really in the old version.  This patch doesn't touch them yet;
this is basically a one-for-one swapout to lay groundwork.  I'd like to
do more with the extended stuff after I do the Doxygen pieces.

Tested constantly on linux, applied to mainline after discussion with
the other maintainers.


concept_check.patch.bz2


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]