stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Sebor (JIRA)" <j...@apache.org>
Subject [jira] Commented: (STDCXX-234) std::distance() declaration incorrect
Date Thu, 06 Sep 2007 00:15:33 GMT

    [ https://issues.apache.org/jira/browse/STDCXX-234?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12525261
] 

Martin Sebor commented on STDCXX-234:
-------------------------------------

Here's a test case and the result of compiling it with gcc:

$ cat t.cpp && make t
#include <iterator>

struct X: std::iterator<std::random_access_iterator_tag, int> { };

template <> std::iterator_traits<X>::difference_type
std::distance (X, X) { return 0; }

int main ()
{
    return std::distance (X (), X ());
}
gcc -c -I/amd/devco/sebor/stdcxx-4.1.3/include/ansi -D_RWSTDDEBUG   -pthread -D_RWSTD_USE_CONFIG
-I/build/sebor/stdcxx-4.1.3-gcc-3.4.3_6-15D/include -I/amd/devco/sebor/stdcxx-4.1.3/include
-I/amd/devco/sebor/stdcxx-4.1.3/examples/include  -pedantic -nostdinc++ -g  -m64 -Wall -W
-Wcast-qual -Winline -Wshadow -Wwrite-strings -Wno-long-long -Wcast-align  t.cpp
t.cpp:6: error: template-id `distance<>' for `long int std::distance(X, X)' does not
match any template declaration
t.cpp:6: error: invalid function declaration
/amd/devco/sebor/stdcxx-4.1.3/include/rw/_iterbase.h: In function `void std::__distance(const
_RandomAccessIterator&, const _RandomAccessIterator&, _Distance&, std::random_access_iterator_tag)
[with _RandomAccessIterator = X, _Distance = long int]':
/amd/devco/sebor/stdcxx-4.1.3/include/rw/_iterbase.h:336:   instantiated from `typename std::iterator_traits<_Iterator>::difference_type
std::distance(const _ForwardIterator&, const _ForwardIterator&) [with _ForwardIterator
= X]'
t.cpp:10:   instantiated from here
/amd/devco/sebor/stdcxx-4.1.3/include/rw/_iterbase.h:323: error: no match for 'operator-'
in '__last - __first'
make: *** [t.o] Error 1


> std::distance() declaration incorrect
> -------------------------------------
>
>                 Key: STDCXX-234
>                 URL: https://issues.apache.org/jira/browse/STDCXX-234
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 24. Iterators
>    Affects Versions: 4.1.2, 4.1.3
>         Environment: all
>            Reporter: Martin Sebor
>            Assignee: Martin Sebor
>             Fix For: 4.2
>
>
> Moved from the Rogue Wave bug tracking database:
> ****Created By: sebor @ Jul 01, 2000 02:17:12 PM****
> Subject: Wrong definition for template distance()
> Date: Sat, 1 Jul 2000 00:28:16 -0700
> From: Dennis Handly <dhandly@hpcllmx.cup.hp.com>
> To: sebor@roguewave.com
> CC: dhandly@hpcllmx.cup.hp.com, wanc@cup.hp.com
> I just noticed Perennial test Sec24/2/P24003.C is failing.
> It seems that prototype for std::distance() is incorrect:
>    template <class _ForwardIterator>
>    inline _TYPENAME iterator_traits<_ForwardIterator>::difference_type
>    distance (const _ForwardIterator &__first, const _ForwardIterator &__last)
> The correct version is 24.3.4:
>     template<class InputIterator>
>         typename iterator_traits<InputIterator>::difference_type
>            distance(InputIterator first, InputIterator last);
> Did you change this because of a compiler problem you wrote about??
>  > The following is a list of problems I have encountered while porting
>  > the lib to aCC 3.14.10:
>  >
>  > 1) JAGac61365 (aCC 3.14.10 not dropping top-level cv-qualifiers during
>  >    template argument deduction). This causes compilation errors in
>  >    std::distance<>() (many tests fail to compile).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message