* Re: ext/stl_hashtable.h:313 - computed value not used + question regarding __gnu_cxx
@ 2002-03-18 10:46 Paolo Carlini
2002-03-19 21:50 ` ext/stl_hashtable.h:313 - computed value not used (source included) Dylan Cuthbert
0 siblings, 1 reply; 3+ 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] 3+ messages in thread
* Re: ext/stl_hashtable.h:313 - computed value not used (source included)
2002-03-18 10:46 ext/stl_hashtable.h:313 - computed value not used + question regarding __gnu_cxx Paolo Carlini
@ 2002-03-19 21:50 ` Dylan Cuthbert
0 siblings, 0 replies; 3+ messages in thread
From: Dylan Cuthbert @ 2002-03-19 21:50 UTC (permalink / raw)
To: Paolo Carlini; +Cc: gcc-help
[-- Attachment #1: Type: text/plain, Size: 3873 bytes --]
The attached file has the code that causes the warnings:
compile with "g++ -D __gnu_cxx=std -Wall -Werror testhash.cpp"
The output I get is:
$ g++ -Wall -Werror -D __gnu_cxx=std hashtest.cpp
cc1plus.exe: warnings being treated as errors
/usr/local/include/g++-v3/ext/stl_hashtable.h: In member function
`std::hashtable<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc>&
std::hashtable<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey,
_Alloc>::operator=(const std::hashtable<_Val, _Key, _HashFcn,
_ExtractKey,
_EqualKey, _Alloc>&) [with _Val = std::pair<const char* const, STD_INT>,
_Key = const char*, _HashFcn = std::hash<const char*>, _ExtractKey =
std::_Select1st<std::pair<const char* const, STD_INT> >, _EqualKey =
NameIDMap::eqstr, _Alloc = std::allocator<STD_4BYTE>]':
/usr/local/include/g++-v3/ext/stl_hashtable.h:317: warning: value computed
is
not used
/usr/local/include/g++-v3/ext/stl_hashtable.h:318: warning: value computed
is
not used
/usr/local/include/g++-v3/ext/stl_hashtable.h:319: warning: value computed
is
not used
/usr/local/include/g++-v3/ext/stl_hashtable.h: In member function
`std::hashtable<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey, _Alloc>&
std::hashtable<_Val, _Key, _HashFcn, _ExtractKey, _EqualKey,
_Alloc>::operator=(const std::hashtable<_Val, _Key, _HashFcn,
_ExtractKey,
_EqualKey, _Alloc>&) [with _Val = std::pair<const STD_INT, std::string>,
_Key = STD_INT, _HashFcn = std::hash<int>, _ExtractKey =
std::_Select1st<std::pair<const STD_INT, std::string> >, _EqualKey =
std::equal_to<STD_INT>, _Alloc = std::allocator<std::string>]':
/usr/local/include/g++-v3/ext/stl_hashtable.h:317: warning: value computed
is
not used
/usr/local/include/g++-v3/ext/stl_hashtable.h:318: warning: value computed
is
not used
/usr/local/include/g++-v3/ext/stl_hashtable.h:319: warning: value computed
is
not used
g++ --version gives :
g++ (GCC) 3.1 20020311 (prerelease)
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Is this significantly different to the 20020317 version you mentioned you
were using?
Regards
---------------------------------
Q-Games, Dylan Cuthbert.
http://www.q-games.com
----- Original Message -----
From: "Paolo Carlini" <pcarlini@unitus.it>
To: <dylan@q-games.com>
Cc: <gcc-help@gcc.gnu.org>
Sent: Tuesday, March 19, 2002 3:45 AM
Subject: Re: ext/stl_hashtable.h:313 - computed value not used + question
regarding __gnu_cxx
> 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;
> }
>
>
>
[-- Attachment #2: hashtest.cpp --]
[-- Type: application/octet-stream, Size: 2270 bytes --]
#include <iostream>
#include <cassert>
#include <ext/hash_map>
typedef int STD_INT;
typedef float STD_FLOAT;
typedef int STD_REF;
typedef int STD_4BYTE;
typedef std::string STD_STR;
typedef std::vector<STD_4BYTE> STD_4BYTE_AR;
typedef STD_4BYTE_AR::const_iterator STD_4BYTE_AR_CTIT;
class NameIDMap // desined for name and id map
{
private:
struct eqstr
{
bool operator()( const char* s1, const char* s2 ) const
{
return strcmp(s1, s2) == 0;
}
};
typedef std::hash_map< const char*, STD_INT, std::hash< const char* >, eqstr > atob;
typedef std::hash_map< STD_INT, std::string, std::hash< STD_INT > > btoa;
atob map_ab;
btoa map_ba;
public:
NameIDMap(){}
~NameIDMap(){}
void addKey( const std::string &_a, const STD_INT &_b )
{
if ( map_ab.count(_a.c_str()) > 0 || map_ba.count(_b) > 0 )
{
std::cerr << "key duplication" << std::endl;
assert( 0 );
}
else
{
map_ab[_a.c_str()] = _b;
map_ba[_b] = _a;
}
return;
}
const STD_INT a2b( const std::string &_a )
{
if ( map_ab.count( _a.c_str() ) == 0 ) assert( 0 );
return map_ab[_a.c_str()];
}
const std::string& b2a( const STD_INT &_b )
{
if ( map_ba.count( _b ) == 0 ) assert( 0 );
return map_ba[_b];
}
};
void block_to_map( const STD_4BYTE_AR &_byte, NameIDMap &_string_table )
{
NameIDMap& temp_string_table = _string_table;
int temp_id = 0;
_string_table = NameIDMap(); // Clean the table
STD_4BYTE_AR_CTIT It;
STD_4BYTE_AR_CTIT Begin = _byte.begin();
// STD_4BYTE_AR_CTIT End = _byte.end();
It = Begin;
// Readin the table size ;
int table_size = *(It++); // used to check the size limit
for ( int cnt = 0 ; cnt < table_size; cnt++ )
{
STD_STR line = "";
int byte4size = 0;
byte4size = *(It++);
STD_4BYTE_AR_CTIT strBegin = It;
STD_4BYTE_AR_CTIT strEnd = It + byte4size;
for ( STD_4BYTE_AR_CTIT strIt = strBegin;
strIt != strEnd;
strIt++ )
{
char byte5aschar[5] = {'\0','\0','\0','\0','\0'};
*(reinterpret_cast<STD_4BYTE*>(byte5aschar) ) = *strIt;
line += byte5aschar;
}
temp_string_table.addKey( line , temp_id++ );
std::advance( It, byte4size );
}
}
int main( int argc, char* argv[] )
{
return 0;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* ext/stl_hashtable.h:313 - computed value not used + question regarding __gnu_cxx
@ 2002-03-17 17:16 Dylan Cuthbert
0 siblings, 0 replies; 3+ 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] 3+ messages in thread
end of thread, other threads:[~2002-03-20 5:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-03-18 10:46 ext/stl_hashtable.h:313 - computed value not used + question regarding __gnu_cxx Paolo Carlini
2002-03-19 21:50 ` ext/stl_hashtable.h:313 - computed value not used (source included) Dylan Cuthbert
-- strict thread matches above, loose matches on Subject: below --
2002-03-17 17:16 ext/stl_hashtable.h:313 - computed value not used + question regarding __gnu_cxx Dylan Cuthbert
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).