From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4773 invoked by alias); 13 May 2003 18:05:57 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 1956 invoked from network); 13 May 2003 18:05:25 -0000 Received: from unknown (HELO lifesupport.shutdown.com) (66.93.79.177) by sources.redhat.com with SMTP; 13 May 2003 18:05:25 -0000 Received: (from llewelly@localhost) by lifesupport.shutdown.com (8.11.2/8.11.2) id h4DI1u221941; Tue, 13 May 2003 11:01:56 -0700 (PDT) To: Cc: Subject: 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 References: <56a201c31959$580d5b80$cf6897c2@hetnet.nl> From: LLeweLLyn Reese Date: Tue, 13 May 2003 18:05:00 -0000 In-Reply-To: <56a201c31959$580d5b80$cf6897c2@hetnet.nl> Message-ID: User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2003-05/txt/msg00103.txt.bz2 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 > 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,const lambda_calculus::Port *,lambda_calculus::int_adr,_Select1st *const,lambda_calculus::Port *> >,equal_to,allocator >::_M_bkt_num_key(const lambda_calculus::Port *const &, unsigned int) const': > > stl_hashtable.h:536: instantiated from `hashtable,const lambda_calculus::Port *,lambda_calculus::int_adr,_Select1st lambda_calculus::Port *const,lambda_calculus::Port *> >,equal_to,allocator >::_M_bkt_num(const pair *const,lambda_calculus::Port *> &, unsigned int) const' > > stl_hashtable.h:930: instantiated from `hashtable,const lambda_calculus::Port *,lambda_calculus::int_adr,_Select1st lambda_calculus::Port *const,lambda_calculus::Port *> >,equal_to,allocator >::resize(unsigned int)' > > stl_hashtable.h:744: instantiated from `hashtable,const lambda_calculus::Port *,lambda_calculus::int_adr,_Select1st lambda_calculus::Port *const,lambda_calculus::Port *> >,equal_to,allocator >::find_or_insert(const pair *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]