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]
Other format: [Raw text]

Re: string debug-mode solutions


On Thu, May 26, 2005 at 01:28:37AM -0500, Benjamin Kosnik wrote:

> 
> 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.

If the symbols are weak there's no problem with ODR, right?

> 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?

Yes, I agree.  I've got a docs patch that clarifies a couple of things
in debug.html (basically pointing out the design doc explains the string
issue and that inlining or preventing extern templates will work)

I'll update it to reflect the fact that the extern templates are now
automatically turned off (should only be a couple of sentences
difference now)

jon


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