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: [v3] char_traits error checking


On Tue, Mar 12, 2002 at 01:09:40PM -0500, Phil Edwards wrote:
> On Tue, Mar 12, 2002 at 04:18:57PM +0000, Nathan Myers wrote:
> > On Tue, Mar 12, 2002 at 10:49:36AM -0500, Phil Edwards wrote:
> > > 
> > > I looked at this as part of PR 5258. The way the ctors are
> > > arranged in basic_string.tcc doesn't seem to give us any
> > > opportunities to do checking on the arguments: the string data is
> > > built (and dereferenced) in the member init list, so no "if NULL
> > > throw logic_error" is possible unless we break that out into a
> > > ctor body.
> > 
> > Not a problem -- change ": member(p)" to ": member(__throw_if_null(p))".
> 
> True, of course.  I was hoping to make this as fast as possible, given
> that this is an extremely common code path.

Inlining works.  The inline __throw_if_null utility function can use 
the __expected* extension to hint the optimizer.  (Although I would 
expect the optimizer to identify any block containing a throw as an 
unlikely path, with no hint needed!  Jason?)
 
> > For string, it's worth giving a decent diagnostic for null pointers
> > even though we don't have to.  Beginners rely very heavily on string.
> 
> That's what I meant by postcondition.

A postcondition is a guarantee made by the library about the state of
an object after a function returns.  I don't see how it relates to 
exceptions.  Apologies if I'm an idiot.

Nathan Myers
ncm at cantrip dot org


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