This is the mail archive of the mailing list for the GCC 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]

libstdc++/6642: Constness prevents substraction of iterators

>Number:         6642
>Category:       libstdc++
>Synopsis:       Constness prevents substraction of iterators
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Sun May 12 22:26:00 PDT 2002
>Originator:     Oscar Fuentes
>Release:        gcc version 3.1 20020510 (prerelease)
Reading specs from t:\msys\1.0\mingw\bin\..\lib\gcc-lib\i686-pc-mingw32\3.1\specs
Configured with: ../gcc-3.1-20020510/configure --enable-languages=c,c++ --enable-threads=win32 --enable-sjlj-exceptions --prefix=t:/msys/1.0/mingw
Thread model: win32
gcc version 3.1 20020510 (prerelease)
Substraction of iterators being the first operand 'non-const' and the second 'const' are not possible.
#include <string>

class MyClass {
  std::string s;
  std::string::iterator it;
  unsigned pos() const {
    return it - s.begin();


t:/msys/1.0/mingw/include/g++-v3/bits/stl_iterator.h: In constructor 
   _Container>::__normal_iterator(const __gnu_cxx::__normal_iterator<_Iter, 
   _Container>&) [with _Iter = const char*, _Iterator = char*, _Container = 
   std::basic_string<char, std::char_traits<char>, std::allocator<char> >]':
case.cpp:9:   instantiated from here
t:/msys/1.0/mingw/include/g++-v3/bits/stl_iterator.h:589: invalid conversion 
   from `const char* const' to `char*'

-(s.begin() - it) works :-)

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