This is the mail archive of the gcc-help@gcc.gnu.org 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]

Re: hash_map error: passing `const lambda_calculus::int_adr' as `this' argument of `const size_t lambda_calculus::int_adr::operator ()(const lambda_calculus::Port *)' discards qualifiers passing `const lambda_calculus::int_adr' as `this' argument of `const size_t lambda_calculus::int_adr::operator ()(const lambda_calculus::Port *)' discards qualifiers


<buggy@hetnet.nl> writes:

> Have you ever seen this error?,
> 
>  it means that I pass a pointer to a constant object out of it's protected context. Yes I cast it down to a normal pointer indeed. The pointer is actually casted to an integer. I'm keeping a hash of memory adresses with 
> the adresses of kopies of the objects these adresses refer too. So I do not alter this const pointer. Here is the code:
> 
> //hash function object for the Mem_hash
> class int_adr
> {public:
> const size_t operator()(const Port* const a)

gcc's hash_map requires this be a const member function.

>     {  int i;
>      /*haha, fooled ya*/   here is the fooling part that actually works on other compilers
>       const Port * const s= a;//(Port *)a;

The error you report has nothing to do with this.

>       i=(int)s;
>      return i;
>     }
> };
> 
> //hash of memory adresses
> typedef std::hash_map< const Port *, Port *, int_adr , equal_to <const Port * > > Mem_hash;
> 
> all these const identifiers are required by hash_map, the non-standard gnu stl-extension.
> 
> I don't wnat to change code that works with other compilers I need some compiler option or something to disable the error.
> 
> error mess:
> 
> gcc  -g -c -I/sw/pkg/gcc-2.95.2/include/g++-3  -I./loki main.cpp
> stl_hashtable.h: In method `size_t hashtable<pair<const lambda_calculus::Port *const,lambda_calculus::Port *>,const lambda_calculus::Port *,lambda_calculus::int_adr,_Select1st<pair<const lambda_calculus::Port 
> *const,lambda_calculus::Port *> >,equal_to<const lambda_calculus::Port *>,allocator<lambda_calculus::Port *> >::_M_bkt_num_key(const lambda_calculus::Port *const &, unsigned int) const':
> 
> stl_hashtable.h:536:   instantiated from `hashtable<pair<const lambda_calculus::Port *const,lambda_calculus::Port *>,const lambda_calculus::Port *,lambda_calculus::int_adr,_Select1st<pair<const 
> lambda_calculus::Port *const,lambda_calculus::Port *> >,equal_to<const lambda_calculus::Port *>,allocator<lambda_calculus::Port *> >::_M_bkt_num(const pair<const lambda_calculus::Port 
> *const,lambda_calculus::Port *> &, unsigned int) const'
> 
> stl_hashtable.h:930:   instantiated from `hashtable<pair<const lambda_calculus::Port *const,lambda_calculus::Port *>,const lambda_calculus::Port *,lambda_calculus::int_adr,_Select1st<pair<const 
> lambda_calculus::Port *const,lambda_calculus::Port *> >,equal_to<const lambda_calculus::Port *>,allocator<lambda_calculus::Port *> >::resize(unsigned int)'
> 
> stl_hashtable.h:744:   instantiated from `hashtable<pair<const lambda_calculus::Port *const,lambda_calculus::Port *>,const lambda_calculus::Port *,lambda_calculus::int_adr,_Select1st<pair<const 
> lambda_calculus::Port *const,lambda_calculus::Port *> >,equal_to<const lambda_calculus::Port *>,allocator<lambda_calculus::Port *> >::find_or_insert(const pair<const lambda_calculus::Port 
> *const,lambda_calculus::Port *> &)'
> 
> stl_hash_map.h:181:   instantiated from here
> 
> stl_hashtable.h:531: passing `const lambda_calculus::int_adr' as `this' argument of `const size_t lambda_calculus::int_adr::operator ()(const lambda_calculus::Port *)' discards qualifiers
> make: *** [main.o] Error 1
[snip]


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