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]

[PATCH] Tiny tweak of the original fix for 8347


Hi everyone,

Phil's commit of libstdc++/8716 testcase, reminded me of this
tiny tweak of my original fix for 8347 which I'd like to have in:
there is no reason to declare/initialize __dnew so early!

Tested x86-linux; if nobody complains, I will apply it in 1 day.

Ciao, Paolo.

////////////////
2002-12-01  Paolo Carlini  <pcarlini@unitus.it>

	* include/bits/basic_string.tcc
	(basic_string::_S_construct(_InIter, _InIter, const _Alloc&,
	forward_iterator_tag)): Delay the declaration of __dnew.
--- basic_string.tcc.~1.28.~	2002-11-01 18:30:35.000000000 +0100
+++ basic_string.tcc	2002-12-01 12:24:37.000000000 +0100
@@ -137,14 +137,14 @@
       _S_construct(_InIter __beg, _InIter __end, const _Alloc& __a, 
 		   forward_iterator_tag)
       {
-	size_type __dnew = static_cast<size_type>(distance(__beg, __end));
-
 	if (__beg == __end && __a == _Alloc())
 	  return _S_empty_rep()._M_refcopy();
 
 	// NB: Not required, but considered best practice.
 	if (__builtin_expect(__beg == _InIter(), 0))
 	  __throw_logic_error("attempt to create string with null pointer");
+
+	size_type __dnew = static_cast<size_type>(distance(__beg, __end));
 	
 	// Check for out_of_range and length_error exceptions.
 	_Rep* __r = _Rep::_S_create(__dnew, __a);

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