string debug-mode solutions

Benjamin Kosnik bkoz@redhat.com
Thu May 26 07:03:00 GMT 2005


Sorry, I'm behind on this list and making new subjects.

> I see, that could be expected considering how brittle are the inlining
> decisions ;) Now I don't know if we can find a concise way to espress
> the idea that, as long as inling happens, the mechanism works for
> std::string and std::wstring, otherwise doesn't. In any case I thing
> something along this way *is* needed, together with clearly mentioning
> __gnu_debug::string/wstring. For 4_0, at least, maybe for 4.1 we can
> eventually do better.

Hey. Just wondering what status is here.

After reviewing the relevant threads, it looks like much of the
significance of this issue is overblown. (IMHO).  To summarize:

1) string/wstring are a special-case deal for the debug mode, with unique
challenges due to its inclusion in the interface of other libstdc++
components. Some of this is already documented in the debug mode design docs.

2) People who really want to use a debug string should use
__gnu_debug::string explicitly. Again, this is already suggested.

3) Controlling extern template is pretty easy, given the right macro usage.
ie: -D_GLIBCXX_EXTERN_TEMPLATE=0

4) On GNU systems, we can solve this without
additional configuration or build complexity for a single translation
unit by specifying no extern template. The debug-mode translation unit
that use string will have implicit instantiations of the string symbols,
which are weak. By definition, all relevant symbols for debug string
are defined in the translation unit, so there will be no confusion with
non-debug string symbols defined as weak symbols from the explicit
instantiations in the library. For multiple translations units and or
mixed debug/normal mode use, the only solution that will reliably work is
__gnu_debug::string.

Given that, there seem to be four options for proceeding.

a: punt, document that __gnu_debug::string preferred, reliable way
b: document that for string, have to use -O1 or above
c: document that for string, have to use -D_GLIBCXX_EXTERN_TEMPLATE=0
d: fixup c++config so that -D_GLIBCXX_DEBUG automatically does c. This
is the linkage that Doug intended when he was writing this sucker. The patch is
simple, and is attached, but may only work for systems that support
weak symbols.

My suggestion is to do d.

Thoughts?

tested x86/linux
tested x86/linux -D_GLIBCXX_DEBUG

-benjamin
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: p.20050526-2
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20050526/f684bc18/attachment.ksh>


More information about the Libstdc++ mailing list