public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: ext/stl_hashtable.h:313 - computed value not used (source included)
@ 2002-03-20  4:41 Paolo Carlini
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Carlini @ 2002-03-20  4:41 UTC (permalink / raw)
  To: dylan; +Cc: gcc-help

> g++ (GCC) 3.1 20020311 (prerelease)
>
> Is this significantly different to the 20020317 version you mentioned you
> were using?

Yes. I cannot reproduce your problem with current 3.1 snapshots. Indeed, it occurs to me that very
recently some patches went in this area (i.e., warnings about unused variables).

Ciao, Paolo.


^ permalink raw reply	[flat|nested] 2+ 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; 2+ 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] 2+ messages in thread

end of thread, other threads:[~2002-03-20 12:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-03-20  4:41 ext/stl_hashtable.h:313 - computed value not used (source included) Paolo Carlini
  -- strict thread matches above, loose matches on Subject: below --
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

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