Paolo Carlini | 1 Dec 12:40 2002
Picon

[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 <at> 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
 <at>  <at>  -137,14 +137,14  <at>  <at> 
       _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();

(Continue reading)

Gabriel Dos Reis | 1 Dec 15:55 2002
Picon

Re: [PATCH] Tiny tweak of the original fix for 8347

Paolo Carlini <pcarlini <at> unitus.it> writes:

| +
| +	size_type __dnew = static_cast<size_type>(distance(__beg, __end));

Please, do fully qualify the above use of distance() with std::.

If you use a standard function *internally*, not mandated by the
interface then, please don't invoke Koenig lookup.

-- Gaby

Paolo Carlini | 1 Dec 16:11 2002
Picon

Re: [PATCH] Tiny tweak of the original fix for 8347

Gabriel Dos Reis wrote:

>Paolo Carlini <pcarlini <at> unitus.it> writes:
>
>| +
>| +	size_type __dnew = static_cast<size_type>(distance(__beg, __end));
>
>Please, do fully qualify the above use of distance() with std::.
>
>If you use a standard function *internally*, not mandated by the
>interface then, please don't invoke Koenig lookup.
>
Ah, yes, I have already seen some patches from Phil correcting this kind 
of problems.

I will take the occasion to do it for this instance.

Thanks!

Ciao, Paolo.

Paolo Carlini | 1 Dec 18:49 2002
Picon

[PATCH] In basic_string.tcc fully qualify min() uses with std::

Hi!

If I understand well Gaby reply to my last posting, the uses
of min() should be also fully qualified with std::.

Tested x86-linux. Ok?

Ciao, Paolo.

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

	* include/bits/basic_string.tcc
	(basic_string::append(const basic_string&, size_type,
	size_type), basic_string::compare(size_type, size_type,
	const basic_string&), basic_string::compare(size_type,
	size_type, const basic_string&, size_type, size_type),
	basic_string::compare(const _CharT*), basic_string::
	compare(size_type, size_type, const _CharT*),
	basic_string::compare(size_type, size_type, const _CharT*,
	size_type), _S_string_copy(const basic_string&, _CharT*,
	typename _Alloc::size_type)): Fully qualify min() with std::.
 
--- basic_string.tcc.~1.28.~	2002-11-01 18:30:35.000000000 +0100
+++ basic_string.tcc	2002-12-01 18:32:31.000000000 +0100
 <at>  <at>  -578,7 +578,7  <at>  <at> 
       // Iff appending itself, string needs to pre-reserve the
(Continue reading)

Gabriel Dos Reis | 1 Dec 20:09 2002
Picon

Re: [PATCH] In basic_string.tcc fully qualify min() uses with std::

Paolo Carlini <pcarlini <at> unitus.it> writes:

| Hi!
| 
| If I understand well Gaby reply to my last posting, the uses
| of min() should be also fully qualified with std::.
| 
| Tested x86-linux. Ok?

Yes.

Thanks.

-- Gaby

Paolo Carlini | 2 Dec 14:03 2002
Picon

[RFC] libstdc++/8780

Hi Gaby, hi everyone,

I'm looking a bit into this PR. This is the testcase:

//////////
#include <vector>

template<int> struct static_assert_test{};

template <bool> struct STATIC_ASSERTION_FAILURE;
template <> struct STATIC_ASSERTION_FAILURE<true>{};

#define BOOST_STATIC_ASSERT( B ) static_assert_test<sizeof(STATIC_ASSERTION_FAILURE< ( B ) >)>

template <typename T> struct is_pointer_helper
{ static const bool value = false; };
template <typename T> struct is_pointer_helper<T*>
{ static const bool value = true; };
template <typename T> struct is_pointer_helper<T*const>
{ static const bool value = true; };
template <typename T> struct is_pointer_helper<T*volatile>
{ static const bool value = true; };
template <typename T> struct is_pointer_helper<T*const volatile>
{ static const bool value = true; };

int main(void)
{
	BOOST_STATIC_ASSERT(is_pointer_helper<std::vector<int>::iterator>::value);

	return(0);
(Continue reading)

Gabriel Dos Reis | 2 Dec 14:09 2002
Picon

Re: [RFC] libstdc++/8780

Hi,

Paolo Carlini <pcarlini <at> unitus.it> writes:

[...]

| The compilation fails with any v3. This seems due to the fact that,
| whereas in v2, for std::vector, simply:
| 
|   typedef value_type* iterator;
| 
| in v3:
| 
|   typedef __gnu_cxx::__normal_iterator<pointer, vector_type> iterator;
| 
| Submitter cites 24.1,(1,2) as implying that the current implementation is
| non conforming.

The submitter is confused.  I would like to see the exact wording from
those paragraphs that may imply that a vector<>::iterator ought to be
a pointer. 

| This seems to me non at all obvious! It is just a QoI issue?
| (in few other widespread implementations iterator *is* just a pointer)

This is a QoI.  I would expect a decent implementation to distinguish
a vector<>::iterator from a plain pointer. 

| Much more generally, I'm interested in knowing why the implementation
| of iterator was changed in such a way in the transition between v2 and v3.
(Continue reading)

Paolo Carlini | 2 Dec 14:35 2002
Picon

Re: [RFC] libstdc++/8780

Gabriel Dos Reis wrote:

>The submitter is confused.  I would like to see the exact wording from
>those paragraphs that may imply that a vector<>::iterator ought to be
>a pointer. 
>
>
>| This seems to me non at all obvious! It is just a QoI issue?
>| (in few other widespread implementations iterator *is* just a pointer)
>
>This is a QoI.  I would expect a decent implementation to distinguish
>a vector<>::iterator from a plain pointer. 
>
>| Much more generally, I'm interested in knowing why the implementation
>| of iterator was changed in such a way in the transition between v2 and v3.
>
Thanks Gaby for your feedback. I have changed the status to <feedback>,
adding to the audit trial your comments.

Ciao, Paolo.

Paolo Carlini | 2 Dec 20:02 2002
Picon

[Patch] Qualify less() and min() in basic_string.h

Hi,

same issue, different v3 file. Seems safe to me.

Tested x86-linux, if nobody complains will commit tomorrow.

Ciao, Paolo.

//////////////
2002-12-02  Paolo Carlini  <pcarlini <at> unitus.it>

	* include/bits/basic_string.h
	(assign(const _CharT*, size_type), insert(size_type,
	const _CharT*, size_type), replace(size_type, size_type,
	const _CharT*, size_type)): Fully qualify less() with std::.
	(compare(const basic_string&)): Ditto for min().
--- basic_string.h.~1.26.~	2002-09-11 01:19:10.000000000 +0200
+++ basic_string.h	2002-12-02 01:30:50.000000000 +0100
 <at>  <at>  -514,8 +514,8  <at>  <at> 
       {
 	if (__n > this->max_size())
 	  __throw_length_error("basic_string::assign");
-	if (_M_rep()->_M_is_shared() || less<const _CharT*>()(__s, _M_data())
-	    || less<const _CharT*>()(_M_data() + this->size(), __s))
+	if (_M_rep()->_M_is_shared() || std::less<const _CharT*>()(__s, _M_data())
+	    || std::less<const _CharT*>()(_M_data() + this->size(), __s))
 	  return _M_replace_safe(_M_ibegin(), _M_iend(), __s, __s + __n);
(Continue reading)

Gabriel Dos Reis | 2 Dec 20:14 2002
Picon

Re: [Patch] Qualify less() and min() in basic_string.h

Paolo Carlini <pcarlini <at> unitus.it> writes:

| Hi,
| 
| same issue, different v3 file. Seems safe to me.
| 
| Tested x86-linux, if nobody complains will commit tomorrow.
| 
| Ciao, Paolo.
| 
| //////////////
| 2002-12-02  Paolo Carlini  <pcarlini <at> unitus.it>
| 
| 	* include/bits/basic_string.h
| 	(assign(const _CharT*, size_type), insert(size_type,
| 	const _CharT*, size_type), replace(size_type, size_type,
| 	const _CharT*, size_type)): Fully qualify less() with std::.
| 	(compare(const basic_string&)): Ditto for min().--- basic_string.h.~1.26.~	2002-09-11
01:19:10.000000000 +0200
| +++ basic_string.h	2002-12-02 01:30:50.000000000 +0100
|  <at>  <at>  -514,8 +514,8  <at>  <at> 
|        {
|  	if (__n > this->max_size())
|  	  __throw_length_error("basic_string::assign");
| -	if (_M_rep()->_M_is_shared() || less<const _CharT*>()(__s, _M_data())
| -	    || less<const _CharT*>()(_M_data() + this->size(), __s))
| +	if (_M_rep()->_M_is_shared() || std::less<const _CharT*>()(__s, _M_data())
| +	    || std::less<const _CharT*>()(_M_data() + this->size(), __s))

This is unnecessary, but I guess it won't make any ill.  Koenig lookup
(Continue reading)


Gmane