public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* Re: STL iterator problem (egcs-1.1.2)
  1999-07-31 23:33 STL iterator problem (egcs-1.1.2) Chris Rankin
@ 1999-07-03 10:44 ` Alexandre Oliva
  0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Oliva @ 1999-07-03 10:44 UTC (permalink / raw)
  To: Chris Rankin; +Cc: egcs-bugs

On Jul  2, 1999, Chris Rankin <rankinc@zip.com.au> wrote:

> I hope that this is a minor problem, what with the gcc release just
> around the corner.
> The included program does not compile:

After adding a closing bracket for main, it only complains about:

teststl.cpp: In function `int main()':
teststl.cpp:23: no match for `reverse_iterator<const int *> & !=
reverse_iterator<int *>'

Which is indeed correct.  It may be regarded as an STL problem, and so
it might be fixed in the next import of SGI STL, or the problem should
be reported to the maintainers of SGI STL, which we simply
re-distribute.  In order to avoid this problem, instead of writing:

>   NumberCollection::const_reverse_iterator  riter;

>   for (riter = num_collect.rbegin();
>        riter != num_collect.rend();
>        ++riter)
>   {

I write:

for (NumberCollection::const_reverse_iterator riter=..., eiter=...end();
     riter != eiter; ++riter) ...

which compiles fine.

-- 
Alexandre Oliva http://www.dcc.unicamp.br/~oliva IC-Unicamp, Bra[sz]il
{oliva,Alexandre.Oliva}@dcc.unicamp.br  aoliva@{acm.org,computer.org}
oliva@{gnu.org,kaffe.org,{egcs,sourceware}.cygnus.com,samba.org}
*** E-mail about software projects will be forwarded to mailing lists


^ permalink raw reply	[flat|nested] 2+ messages in thread

* STL iterator problem (egcs-1.1.2)
@ 1999-07-31 23:33 Chris Rankin
  1999-07-03 10:44 ` Alexandre Oliva
  0 siblings, 1 reply; 2+ messages in thread
From: Chris Rankin @ 1999-07-31 23:33 UTC (permalink / raw)
  To: egcs-bugs

Hi,
I hope that this is a minor problem, what with the gcc release just
around the corner.
The included program does not compile:

g++ -O2 -march=pentium -fstrict-prototypes -felide-constructors
-fnonnull-object
s -fno-strict-aliasing  -I../Debug/ -Wall -Wshadow -Wsign-compare
-Wwrite-string
s -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith
-Wmissing-declaration
s -o teststl teststl.cpp
/usr/include/g++/std/bastring.h: In method
`basic_string<charT,traits,Allocator>
::basic_string(InputIterator, InputIterator)':
In file included from /usr/include/g++/string:6,
                 from teststl.cpp:3:
/usr/include/g++/std/bastring.h:153: warning: declaration of `end'
shadows a mem
ber of `this'
/usr/include/g++/std/bastring.h:153: warning: declaration of `begin'
shadows a m
ember of `this'
/usr/include/g++/std/bastring.cc: In method `void
basic_string<charT,traits,Allo
cator>::alloc(size_t, bool)':
In file included from /usr/include/g++/std/bastring.h:618,
                 from /usr/include/g++/string:6,
                 from teststl.cpp:3:
/usr/include/g++/std/bastring.cc:98: warning: declaration of `size'
shadows a me
mber of `this'
/usr/include/g++/stl_iterator.h: In method `reverse_iterator<const int
*>::rever
se_iterator<int *>(const class reverse_iterator<int *> &)':
teststl.cpp:22:   instantiated from here
/usr/include/g++/stl_iterator.h:548: member `current' is a protected
member of c
lass `reverse_iterator<int *>'
teststl.cpp: In function `int main()':
teststl.cpp:23: no match for `reverse_iterator<const int *> & !=
reverse_iterato
r<int *>'
make: *** [teststl] Error 1

-----------------------------------------------------------------------------

#include <iostream>
#include <vector>
using namespace std;

typedef  vector<int>  NumberCollection;

int
main()
{
  NumberCollection  num_collect;

  for (int i = 0; i < 100; ++i)
  {
    num_collect.push_back(i);
  } /* for */

  NumberCollection::const_reverse_iterator  riter;

  for (riter = num_collect.rbegin();
       riter != num_collect.rend();
       ++riter)
  {
    cout << *riter << endl;
  } /* for */
                                                                  
$ g++ -v
Reading specs from /usr/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)

(I also see this compiling with egcs-1.1.2 on Solaris 2.6)

Cheers,
Chris.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1999-07-31 23:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-07-31 23:33 STL iterator problem (egcs-1.1.2) Chris Rankin
1999-07-03 10:44 ` Alexandre Oliva

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).