public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* ext/stl_hashtable.h:313 - computed value not used + question regarding __gnu_cxx
@ 2002-03-17 17:16 Dylan Cuthbert
  0 siblings, 0 replies; 2+ messages in thread
From: Dylan Cuthbert @ 2002-03-17 17:16 UTC (permalink / raw)
  To: gcc-help

Hello there

I hate to repeat a mail but seeing as there was no response and I'm sure
someone has a simple yes/no answer regarding my fix below, I've sent it
again with another question as it seems fairly important to get this fixed
for gcc 3.1.

I compile with -D __gnu_cxx=std in order to use these ext libraries - is
this a no-no?  Do I have to use the ugly __gnu_cxx:: namespace specifier or
can I get away with this define?

--- previous mail ---

I get warnings from including ext/hash_map extended stl libraries.. the
warning occurs in ext/stl_hashtable.h:313 and I fixed it by doing the
following (I think)

  hashtable& operator= (const hashtable& __ht)
  {
    if (&__ht != this) {
      clear();
      (void)(_M_hash = __ht._M_hash );
      (void)(_M_equals = __ht._M_equals );
      (void)(_M_get_key = __ht._M_get_key );
      _M_copy_from(__ht);
    }
    return *this;
  }

I added the (void)'s to prevent a "computed value is not used" warning.  I
would prefer not to have to switch -Wall and -Werror off so is this the
proper way to fix this?

Also the warning/error output didn't tell me which line (or file even!) the
code was in that was invoking the above function - which makes finding the
lines involved rather difficult.

Regards


---------------------------------
有限会社 Q-Games, Dylan Cuthbert.
http://www.q-games.com/personal/utils

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

* Re: ext/stl_hashtable.h:313 - computed value not used + question  regarding __gnu_cxx
@ 2002-03-18 10:46 Paolo Carlini
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Carlini @ 2002-03-18 10:46 UTC (permalink / raw)
  To: dylan; +Cc: gcc-help

Hi,

> I get warnings from including ext/hash_map extended stl libraries.. the
> warning occurs in ext/stl_hashtable.h:313

Can you please be more specific (i.e., code snippet triggering the warning, 3.1
snapshot you are testing, etc.) ??

With 3.1 20020317 I can compile -Wall -Werror the example below with no warnings
at all.

Thanks,
Paolo.

///////////////

#include <ext/hash_map>
#include <iostream>

using namespace __gnu_cxx;
using namespace std;

struct eqstr
{
  bool operator()(const char* s1, const char* s2) const
  {
    return strcmp(s1, s2) == 0;
  }
};

int main()
{
  hash_map<const char*, int, hash<const char*>, eqstr> months;

  months["january"] = 31;
  months["february"] = 28;
  months["march"] = 31;
  months["april"] = 30;
  months["may"] = 31;
  months["june"] = 30;
  months["july"] = 31;
  months["august"] = 31;
  months["september"] = 30;
  months["october"] = 31;
  months["november"] = 30;
  months["december"] = 31;

  cout << "september -> " << months["september"] << endl;
  cout << "april     -> " << months["april"] << endl;
  cout << "june      -> " << months["june"] << endl;
  cout << "november  -> " << months["november"] << endl;
}



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

end of thread, other threads:[~2002-03-18 18:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-03-17 17:16 ext/stl_hashtable.h:313 - computed value not used + question regarding __gnu_cxx Dylan Cuthbert
2002-03-18 10:46 Paolo Carlini

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).