Bug in include/bits/stl_iterator.h?

Phil Edwards phil@jaj.com
Fri May 30 18:49:00 GMT 2003


On Thu, May 29, 2003 at 04:03:56PM -0700, Nathan Myers wrote:
> 
>     // NB: Not required, but considered best practice.
>     if (__builtin_expect(__beg == _InIter(), 0))
>       __throw_logic_error("basic_string::_S_construct NULL not valid");
[...]
> 
> we should eliminate this check from basic_string.tcc and anywhere 
> else it (or its like) appears.

I think you misspelled "we should find some other way of performing this
highly useful check which catches a common programming error."

Beginning (and even intermediate) users construct basic_strings from NULL
all the time.  Trust me, I get asked about it quite a bit.  They seem to
expect that the result should be equivalent to basic_string(""), which I
agree would be wrong on many levels, but to not check the argument against
NULL at all would just be needlessly confusing.


Phil

-- 
If ye love wealth greater than liberty, the tranquility of servitude greater
than the animating contest for freedom, go home and leave us in peace.  We seek
not your counsel, nor your arms.  Crouch down and lick the hand that feeds you;
and may posterity forget that ye were our countrymen.            - Samuel Adams



More information about the Libstdc++ mailing list