You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stdcxx.apache.org by Anton Pevtsov <An...@moscow.vdiweb.com> on 2006/07/06 16:26:48 UTC

RE: svn commit: r414916 - /incubator/stdcxx/trunk/tests/include/alg_test.h

Martin, I've noted that this commitment brokes several algorithms test
(on MSVC).
They used make_iter in the following way:

const Iterator first = make_iter (xsrc, xsrc, xsrc + nsrc, dummy_it);

And this results in the error:

error C2666: 'make_iter' : 2 overloads have similar conversions
        ..stdcxx\tests\algorithms\..\include\alg_test.h(1233): could be
'FwdIter make_iter(T *,const T *,const T *,FwdIter)'
        with
        [
            T=X
        ]
        ..stdcxx\tests\algorithms\..\include\alg_test.h(1252): or
'ConstFwdIter make_iter(const T *,const T *,const T *,ConstFwdIter)'
        with
        [
            T=X
        ]
        while trying to match the argument list '(X *const , X *const ,
X *const , ConstFwdIter)'
        with
        [
            T=X
        ]
        note: qualification adjustment (const/volatile) may be causing
the ambiguity

I suggest to update the tests to use the following:

const Iterator first (xsrc, xsrc, xsrc + nsrc);

The diffs are here:
http://people.apache.org/~antonp/stdcxx07062006/

What do you think about this?

Thanks,
Anton Pevtsov


-----Original Message-----
From: sebor@apache.org [mailto:sebor@apache.org] 
Sent: Saturday, June 17, 2006 01:16
To: stdcxx-commits@incubator.apache.org
Subject: svn commit: r414916 -
/incubator/stdcxx/trunk/tests/include/alg_test.h


Author: sebor
Date: Fri Jun 16 14:15:59 2006
New Revision: 414916

URL: http://svn.apache.org/viewvc?rev=414916&view=rev
Log:
2006-06-16  Martin Sebor  <se...@roguewave.com>

	* alg_test.h (InputIter ctor): Asserted a precondition.
	(InputIter, OutputIter, ...): Changed the actual type
	of difference_type from plain int to ptrdiff_t.
	(make_iter): Made the type of the first argument const T*
	for const iterator overloads of the function template.

Modified:
    incubator/stdcxx/trunk/tests/include/alg_test.h

Modified: incubator/stdcxx/trunk/tests/include/alg_test.h
URL:
http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/include/alg_te
st.h?rev=414916&r1=414915&r2=414916&view=diff
========================================================================
======
--- incubator/stdcxx/trunk/tests/include/alg_test.h (original)
+++ incubator/stdcxx/trunk/tests/include/alg_test.h Fri Jun 16 14:15:59 
+++ 2006
@@ -601,7 +601,7 @@
     typedef T                       value_type;
     typedef value_type*             pointer;
     typedef value_type&             reference;
-    typedef int                     difference_type;
+    typedef _RWSTD_PTRDIFF_T        difference_type;
     typedef std::input_iterator_tag iterator_category;
 
     // body shared by all copies of the same InputIter specialization
@@ -616,7 +616,9 @@
         Shared (const value_type *cur,
                 const value_type *beg,
                 const value_type *end)
-            : cur_ (cur), beg_ (beg), end_ (end), ref_ (1) { }
+            : cur_ (cur), beg_ (beg), end_ (end), ref_ (1) {
+            RW_ASSERT (beg_ <= cur_ && cur_ <= end_);
+        }
 
         ~Shared () {
             cur_ = beg_ = end_ = 0;
@@ -723,7 +725,7 @@
     typedef T                        value_type;
     typedef value_type*              pointer;
     typedef value_type&              reference;
-    typedef int                      difference_type;
+    typedef _RWSTD_PTRDIFF_T         difference_type;
     typedef std::output_iterator_tag iterator_category;
 
     // body shared by all copies of the same OutputIter specialization
@@ -850,7 +852,7 @@
     typedef T                         value_type;
     typedef value_type*               pointer;
     typedef value_type&               reference;
-    typedef int                       difference_type;
+    typedef _RWSTD_PTRDIFF_T          difference_type;
     typedef std::forward_iterator_tag iterator_category;
 
     FwdIter (): cur_ (0), end_ (0) { }
@@ -934,7 +936,7 @@
     typedef T                               value_type;
     typedef value_type*                     pointer;
     typedef value_type&                     reference;
-    typedef int                             difference_type;
+    typedef _RWSTD_PTRDIFF_T                difference_type;
     typedef std::bidirectional_iterator_tag iterator_category;
 
     BidirIter (): cur_ (0), begin_ (0), end_ (0) { }
@@ -1030,7 +1032,7 @@
     typedef T                               value_type;
     typedef value_type*                     pointer;
     typedef value_type&                     reference;
-    typedef int                             difference_type;
+    typedef _RWSTD_PTRDIFF_T                difference_type;
     typedef std::random_access_iterator_tag iterator_category;
 
     RandomAccessIter (): cur_ (0), begin_ (0), end_ (0) { }
@@ -1247,7 +1249,7 @@
 
 template <class T>
 inline ConstFwdIter<T>
-make_iter (T *cur, const T *begin, const T *end, ConstFwdIter<T>)
+make_iter (const T *cur, const T *begin, const T *end, ConstFwdIter<T>)
 {
     return ConstFwdIter<T>(cur, begin, end);
 }
@@ -1285,7 +1287,7 @@
 
 template <class T>
 inline ConstBidirIter<T>
-make_iter (T *cur, const T *begin, const T *end, ConstBidirIter<T>)
+make_iter (const T *cur, const T *begin, const T *end, 
+ConstBidirIter<T>)
 {
     return ConstBidirIter<T>(cur, begin, end);
 }
@@ -1323,7 +1325,7 @@
 
 template <class T>
 inline ConstRandomAccessIter<T>
-make_iter (T *cur, const T *begin, const T *end,
ConstRandomAccessIter<T>)
+make_iter (const T *cur, const T *begin, const T *end, 
+ConstRandomAccessIter<T>)
 {
     return ConstRandomAccessIter<T>(cur, begin, end);
 }



Re: svn commit: r414916 - /incubator/stdcxx/trunk/tests/include/alg_test.h

Posted by Martin Sebor <se...@roguewave.com>.
Anton Pevtsov wrote:
> Martin, I've noted that this commitment brokes several algorithms test
> (on MSVC).
> They used make_iter in the following way:
> 
> const Iterator first = make_iter (xsrc, xsrc, xsrc + nsrc, dummy_it);
> 
> And this results in the error:
> 
> error C2666: 'make_iter' : 2 overloads have similar conversions
[...]
> I suggest to update the tests to use the following:
> 
> const Iterator first (xsrc, xsrc, xsrc + nsrc);
> 
> The diffs are here:
> http://people.apache.org/~antonp/stdcxx07062006/
> 
> What do you think about this?

Those are good changes. There's no reason to use the make_iter
helper in these tests since we're only using the test iterators
and they can all be constructed the same way. The helpers are
there to let us use both the test iterators as well as other
kinds (such as pointers, etc.)

That said, if you suspect an MSVC bug it would be nice to put
together a small test case for the record and report it to
Microsoft: http://connect.microsoft.com.

Martin