This is the mail archive of the gcc-bugs@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]

Warning problems with egcs-1.1 and STL


Dear Sirs and Madams,

I consider it a nuisance when include files warn. Unfortunately when turning on some useful warning options, then the STL warns a lot.

Two suggestions:

 1)  Give us pragmas to turn on/off warnings selectively.
      The whole puristic discussion about pragmas in the manual
      is pointless. Any sane person uses pragmas like this:

        #if defined _MSC_VER
        # pragma warn(blabla)
        #elif defined __GNUG__
        # pragma warn(bla bla)
        #endif

      Bashing pragma for being essentially undefined by any
      standard is wrong. They can be just another way to specify what
      commandline options specify but selectively from within the
      source file. Obviously they are just as non-standard as the
      commanline options are and obviously they are useful in some
      situations.

 2)  Print "error:" in lines which indicate errors. Not just nothing as
      opposed to "warning:". You just can't search for that nothing!!
      When searching a long log file for the serious problems I like
      most what IBM's xlC does: It prints (W) for warnings and (S) for
      errors and (F) for fatal errors (compiler problems). Searching
      for these tokens in the log is most easy.

Attached is the offending log from some harmless STL usage with
some most useful warnings turned on.

I'm using egcs-1.1b on Linux, with pcg patches applied.

Best regards
Dirk Zoller
-- 
Dirk Zoller 
Remove '_' from the e-mail adress.
 
cd /home/duz/pnl/stl/
rm -f *.s; make -k stl_virtual.s RELEASE=yes
gcc -funroll-loops -I/home/duz/pnl/include/ -fPIC -pipe -Wall -mpentium -Wall -W -Wcast-align -Wmissing-declarations -Woverloaded-virtual -Wwrite-strings -fno-exceptions -fno-rtti -fnew-abi -fvtable-thunks -fno-implicit-templates -fno-exceptions -O6 -fomit-frame-pointer -S stl_virtual.cc -o stl_virtual.s-
/usr/local/include/g++/stl_alloc.h: In function `static void ** simple_alloc<void *,virtual_cmp>::allocate<void *, virtual_cmp>(unsigned int)':
/usr/local/include/g++/stl_vector.h:334:   instantiated from `vector<void *,virtual_cmp>::insert_aux<void *, virtual_cmp>(void **, void *const &)'
stl_virtual.cc:33:   instantiated from here
/usr/local/include/g++/stl_alloc.h:221: no method `virtual_cmp::allocate'
/usr/local/include/g++/stl_alloc.h:221: warning: control reaches end of non-void function `simple_alloc<void *,virtual_cmp>::allocate<void *, virtual_cmp>(unsigned int)'
/usr/local/include/g++/stl_alloc.h: In function `static void simple_alloc<void *,virtual_cmp>::deallocate<void *, virtual_cmp>(void **, unsigned int)':
/usr/local/include/g++/stl_vector.h:69:   instantiated from `vector<void *,virtual_cmp>::deallocate<void *, virtual_cmp>()'
/usr/local/include/g++/stl_vector.h:351:   instantiated from `vector<void *,virtual_cmp>::insert_aux<void *, virtual_cmp>(void **, void *const &)'
stl_virtual.cc:33:   instantiated from here
/usr/local/include/g++/stl_alloc.h:225: no method `virtual_cmp::deallocate'
/usr/local/include/g++/stl_vector.h: In method `void vector<void *,virtual_cmp>::insert_aux<void *, virtual_cmp>(void **, void *const &)':
stl_virtual.cc:33:   instantiated from here
/usr/local/include/g++/stl_vector.h:334: warning: `void ** new_start' might be used uninitialized in this function
/usr/local/include/g++/stl_vector.h: In method `class vector<void *,virtual_cmp> & vector<void *,virtual_cmp>::operator =<void *, virtual_cmp>(const class vector<void *,virtual_cmp> &)':
stl_virtual.cc:33:   instantiated from here
/usr/local/include/g++/stl_vector.h:226: warning: `void ** result' might be used uninitialized in this function
/usr/local/include/g++/stl_vector.h: In method `void vector<void *,virtual_cmp>::insert<void *, virtual_cmp>(void **, unsigned int, void *const &)':
/usr/local/include/g++/stl_vector.h:183:   instantiated from `vector<void *,virtual_cmp>::insert<void *, virtual_cmp>(void **, long int, void *const &)'
/usr/local/include/g++/stl_vector.h:167:   instantiated from `vector<void *,virtual_cmp>::insert<void *, virtual_cmp>(void **)'
stl_virtual.cc:33:   instantiated from here
/usr/local/include/g++/stl_vector.h:382: warning: `void ** new_start' might be used uninitialized in this function
/usr/local/include/g++/stl_hashtable.h: In method `hashtable<void *,void *,virtual_hash,identity<void *>,equal_to<void *>,__default_alloc_template<false,0> >::hashtable<void *, void *, virtual_hash, identity<void *>, equal_to<void *>, alloc>(unsigned int, const struct virtual_hash &, const struct equal_to<void *> &)':
/usr/local/include/g++/stl_hash_set.h:74:   instantiated from `hash_set<void *,virtual_hash,equal_to<void *>,__default_alloc_template<false,0> >::hash_set<void *, virtual_hash, equal_to<void *>, alloc>()'
stl_virtual.cc:36:   instantiated from here
/usr/local/include/g++/stl_hashtable.h:220: warning: value computed is not used
/usr/local/include/g++/stl_algobase.h: In function `void swap<equal_to<void *>>(struct equal_to<void *> &, struct equal_to<void *> &)':
/usr/local/include/g++/stl_hashtable.h:252:   instantiated from `hashtable<void *,void *,virtual_hash,identity<void *>,equal_to<void *>,__default_alloc_template<false,0> >::swap<void *, void *, virtual_hash, identity<void *>, equal_to<void *>, alloc>(hashtable<void *,void *,virtual_hash,identity<void *>,equal_to<void *>,__default_alloc_template<false,0> > &)'
/usr/local/include/g++/stl_hash_set.h:124:   instantiated from `hash_set<void *,virtual_hash,equal_to<void *>,__default_alloc_template<false,0> >::swap<void *, virtual_hash, equal_to<void *>, alloc>(hash_set<void *,virtual_hash,equal_to<void *>,__default_alloc_template<false,0> > &)'
stl_virtual.cc:36:   instantiated from here
/usr/local/include/g++/stl_algobase.h:76: warning: statement with no effect
/usr/local/include/g++/stl_algobase.h:77: warning: statement with no effect
/usr/local/include/g++/stl_algobase.h: In function `void swap<identity<void *>>(struct identity<void *> &, struct identity<void *> &)':
/usr/local/include/g++/stl_hashtable.h:253:   instantiated from `hashtable<void *,void *,virtual_hash,identity<void *>,equal_to<void *>,__default_alloc_template<false,0> >::swap<void *, void *, virtual_hash, identity<void *>, equal_to<void *>, alloc>(hashtable<void *,void *,virtual_hash,identity<void *>,equal_to<void *>,__default_alloc_template<false,0> > &)'
/usr/local/include/g++/stl_hash_set.h:124:   instantiated from `hash_set<void *,virtual_hash,equal_to<void *>,__default_alloc_template<false,0> >::swap<void *, virtual_hash, equal_to<void *>, alloc>(hash_set<void *,virtual_hash,equal_to<void *>,__default_alloc_template<false,0> > &)'
stl_virtual.cc:36:   instantiated from here
/usr/local/include/g++/stl_algobase.h:76: warning: statement with no effect
/usr/local/include/g++/stl_algobase.h:77: warning: statement with no effect
/usr/local/include/g++/stl_hashtable.h: In method `hashtable<pair<void *const,void *>,void *,virtual_hash,select1st<pair<void *const,void *> >,equal_to<void *>,__default_alloc_template<false,0> >::hashtable<pair<void *const,void *>, void *, virtual_hash, select1st<pair<void *const,void *> >, equal_to<void *>, alloc>(unsigned int, const struct virtual_hash &, const struct equal_to<void *> &)':
/usr/local/include/g++/stl_hash_map.h:78:   instantiated from `hash_map<void *,void *,virtual_hash,equal_to<void *>,__default_alloc_template<false,0> >::hash_map<void *, void *, virtual_hash, equal_to<void *>, alloc>()'
stl_virtual.cc:39:   instantiated from here
/usr/local/include/g++/stl_hashtable.h:220: warning: value computed is not used
/usr/local/include/g++/stl_algobase.h: In function `void swap<select1st<pair<void *const,void *> >>(struct select1st<pair<void *const,void *> > &, struct select1st<pair<void *const,void *> > &)':
/usr/local/include/g++/stl_hashtable.h:253:   instantiated from `hashtable<pair<void *const,void *>,void *,virtual_hash,select1st<pair<void *const,void *> >,equal_to<void *>,__default_alloc_template<false,0> >::swap<pair<void *const,void *>, void *, virtual_hash, select1st<pair<void *const,void *> >, equal_to<void *>, alloc>(hashtable<pair<void *const,void *>,void *,virtual_hash,select1st<pair<void *const,void *> >,equal_to<void *>,__default_alloc_template<false,0> > &)'
/usr/local/include/g++/stl_hash_map.h:128:   instantiated from `hash_map<void *,void *,virtual_hash,equal_to<void *>,__default_alloc_template<false,0> >::swap<void *, void *, virtual_hash, equal_to<void *>, alloc>(hash_map<void *,void *,virtual_hash,equal_to<void *>,__default_alloc_template<false,0> > &)'
stl_virtual.cc:39:   instantiated from here
/usr/local/include/g++/stl_algobase.h:76: warning: statement with no effect
/usr/local/include/g++/stl_algobase.h:77: warning: statement with no effect
/usr/local/include/g++/stl_vector.h: In method `void vector<void *,virtual_cmp>::reserve<void *, virtual_cmp>(unsigned int)':
/usr/local/include/g++/stl_vector.h:226: warning: `void ** result' might be used uninitialized in this function
/usr/local/include/g++/stl_vector.h: In method `vector<void *,virtual_cmp>::vector<void *, virtual_cmp>(const class vector<void *,virtual_cmp> &)':
/usr/local/include/g++/stl_vector.h:226: warning: `void ** result' might be used uninitialized in this function
/usr/local/include/g++/stl_vector.h: In method `vector<void *,virtual_cmp>::vector<void *, virtual_cmp>(unsigned int)':
/usr/local/include/g++/stl_vector.h:214: warning: `void ** result' might be used uninitialized in this function
/usr/local/include/g++/stl_vector.h: In method `vector<void *,virtual_cmp>::vector<void *, virtual_cmp>(long int, void *const &)':
/usr/local/include/g++/stl_vector.h:214: warning: `void ** result' might be used uninitialized in this function
/usr/local/include/g++/stl_vector.h: In method `vector<void *,virtual_cmp>::vector<void *, virtual_cmp>(int, void *const &)':
/usr/local/include/g++/stl_vector.h:214: warning: `void ** result' might be used uninitialized in this function
/usr/local/include/g++/stl_vector.h: In method `vector<void *,virtual_cmp>::vector<void *, virtual_cmp>(unsigned int, void *const &)':
/usr/local/include/g++/stl_vector.h:214: warning: `void ** result' might be used uninitialized in this function
/usr/local/include/g++/stl_vector.h: In method `void vector<void *,virtual_cmp>::fill_initialize<void *, virtual_cmp>(unsigned int, void *const &)':
/usr/local/include/g++/stl_vector.h:214: warning: `void ** result' might be used uninitialized in this function
/usr/local/include/g++/stl_vector.h: In method `void ** vector<void *,virtual_cmp>::allocate_and_fill<void *, virtual_cmp>(unsigned int, void *const &)':
/usr/local/include/g++/stl_vector.h:214: warning: `void ** result' might be used uninitialized in this function
make: *** [stl_virtual.s] Error 1

Compilation exited abnormally with code 2 at Wed Sep 16 08:19:23
// $Id$


#ifdef __GNUG__
#pragma implementation
#endif

#include "stl_virtual.hh"


// Useless implementations but STL doesn't instantiate on pure virtual
// `Compare' and `Hash' classes.

bool
virtual_cmp::operator() (const void *a, const void *b) const
{
  return a < b;
}

unsigned
virtual_hash::operator() (const void *a) const
{
  return unsigned (a);
}

bool
virtual_hash::eq (const void *a, const void *b) const
{
  return a == b;
}


template class vector	< void *, virtual_cmp >;
template class set	< void *, virtual_cmp >;
template class multiset	< void *, virtual_cmp >;
template class hash_set < void *, virtual_hash >;
template class map	< void *, void *, virtual_cmp >;
template class multimap	< void *, void *, virtual_cmp >;
template class hash_map < void *, void *, virtual_hash >;
// $Id$


#ifndef STL_VIRTUAL_HH
#define STL_VIRTUAL_HH

#ifdef __GNUG__
#pragma interface
#endif

#include <vector>
#include <set>
#include <map>
#include <hash_set>
#include <hash_map>


struct virtual_cmp
{
  virtual bool operator() (const void *, const void *) const;
};

struct virtual_hash
{
  virtual unsigned operator() (const void *) const;
  virtual bool eq (const void *, const void *) const;
};


extern template class vector	< void *, virtual_cmp >;
extern template class set	< void *, virtual_cmp >;
extern template class multiset	< void *, virtual_cmp >;
extern template class hash_set	< void *, virtual_hash >;
extern template class map	< void *, void *, virtual_cmp >;
extern template class multimap	< void *, void *, virtual_cmp >;
extern template class hash_map	< void *, void *, virtual_hash >;

typedef vector	< void *, virtual_cmp >		virtual_vector;
typedef set	< void *, virtual_cmp >		virtual_set;
typedef multiset< void *, virtual_cmp >		virtual_multiset;
typedef hash_set< void *, virtual_hash >	virtual_hash_set;
typedef map	< void *, void *, virtual_cmp > virtual_map;
typedef multimap< void *, void *, virtual_cmp > virtual_multimap;
typedef hash_map< void *, void *, virtual_hash >virtual_hash_map;


#endif//STL_VIRTUAL_HH

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