This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Bug in include/bits/stl_iterator.h?
- From: Phil Edwards <phil at jaj dot com>
- To: libstdc++ at gcc dot gnu dot org
- Date: Thu, 29 May 2003 20:13:51 -0400
- Subject: Re: Bug in include/bits/stl_iterator.h?
- References: <20030529230356.GD20829@tofu.dreamhost.com>
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