This is the mail archive of the libstdc++@sources.redhat.com mailing list for the libstdc++ project.


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

Re: compile problem with std::map::const_iterator


Lars Gullik BjXnnes wrote:
> 
> larsbj@lyx.org (Lars Gullik Bjønnes) writes:
> 
> I can confirm that I still have these problems with
> 
> Reading specs from /usr/local/lib/gcc-lib/i586-pc-linux-gnu/2.97/specs
> Configured with:  --with-gcc-version-trigger=/local/larsbj/gcc/gcc/version.c --host=i586-pc-linux-gnu --enable-libstdcxx-v3 --enable-languages=c++ --enable-shared --norecursion
> gcc version 2.97 20001014 (experimental)
> 
> Should I post a more formal bug report?
> 
>         Lgb
> 
> | tested on libstdc++-v3 as of
> | Reading specs from /usr/local/lib/gcc-lib/i586-pc-linux-gnu/2.97/specs
> | gcc version 2.97 20001001 (experimental)
> |
> | #include <map>
> |
> | int main()
> | {
> |         typedef std::map<void *, void *> Cache;
> |
> |         Cache cache;
> |
> |         for (Cache::const_iterator cit = cache.begin();
> |              cit != cache.end(); ++cit) {
> |                 ;
> |         }
> | }
> |
> | This does not compile.
> |
> | [larsbj@lett test]$ g++ -W -Wall -O2 -o testmap testmap.C
> | testmap.C: In function `int main()':
> | testmap.C:10: no match for `std::_Rb_tree_iterator<std::pair<void *const, void
> |    *>, const std::pair<void *const, void *> &, const std::pair<void *const,
> |    void *> *> & != std::_Rb_tree_iterator<std::pair<void *const, void *>,
> |    std::pair<void *const, void *> &, std::pair<void *const, void *> *>'
> |
> | If I change to use Cache::iterator it compiles.
> |
> | Unsure if this is user,compiler or lib problem...

unfortunately it seems to be a compiler bug. if you have a class with 2 function
with the same signature but one of them are const, compiler will choose the
const if you call it on a const object (which is corret), but if you call it 
on a non-const object it's always call the non-const version even if it's
produce and error (in this case the compiler sould have choose the const
version:-()

I notice this one but never make a bugreport for gcc. someone willing do so ?


 -- Levente                        http://petition.eurolinux.org/index_html
 "The only thing worse than not knowing the truth is
  ruining the bliss of ignorance."

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