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]

2.95.2 Alpha C++ STL <vector> -Wcast-align gives many warnings


On an alphaev56-dec-osf4.0d system, g++ 2.95.2 -Wcast-align gives many
warnings "warning: cast increases required alignment of target type" when
compiling programs which use (the STL header file provided with 2.95.2)
<vector>.  For example, this program

   #include <vector>
   using namespace std;
   
   class   gridfn_vector
           {
   public:
           gridfn_vector()
                   : N_gridfns_(0),
                     gfns_(0)
                   { }
           ~gridfn_vector()
                   { }
   
   private:
           // we forbid copying and passing by value
           // by declaring the copy constructor and assignment operator
           // private, but never defining them
           gridfn_vector(const gridfn_vector &rhs);
           gridfn_vector& operator=(const gridfn_vector &rhs);
   
   private:
           int N_gridfns_;
           vector<int> gfns_;
           };

produces the output

   % /usr/local/apps/gcc-2.95.2/bin/g++ --verbose --save-temps -Wcast-align -c alpha.warn.cc
   Reading specs from /usr/local/apps/gcc-2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/specs
   gcc version 2.95.2 19991024 (release)
    /usr/local/apps/gcc-2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/cpp -lang-c++ -v -D__GNUC__=2 -D__GNUG__=2 -D__GNUC_MINOR__=95 -D__cplusplus -Dunix -D__osf__ -D_LONGLONG -DSYSTYPE_BSD -D_SYSTYPE_BSD -D__unix__ -D__osf__ -D_LONGLONG -D__SYSTYPE_BSD__ -D_SYSTYPE_BSD -D__unix -D__SYSTYPE_BSD -Asystem(unix) -Asystem(xpg4) -D__EXCEPTIONS -Wcast-align -D__LANGUAGE_C_PLUS_PLUS__ -D__LANGUAGE_C_PLUS_PLUS -D__cplusplus -Acpu(alpha) -Amachine(alpha) -D__alpha -D__alpha__ -D__alpha_ev5__ -Acpu(ev5) -D__alpha_bwx__ -Acpu(bwx) alpha.warn.cc alpha.warn.ii
   GNU CPP version 2.95.2 19991024 (release)
   #include "..." search starts here:
   #include <...> search starts here:
    /usr/local/apps/gcc-2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/../../../../include/g++-3
    /usr/local/include
    /usr/local/apps/gcc-2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/../../../../alphaev56-dec-osf4.0d/include
    /usr/local/apps/gcc-2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/include
    /usr/include
   End of search list.
   The following default directories have been omitted from the search path:
   End of omitted list.
    /usr/local/apps/gcc-2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/cc1plus alpha.warn.ii -quiet -dumpbase alpha.warn.cc -Wcast-align -version -o alpha.warn.s
   GNU C++ version 2.95.2 19991024 (release) (alphaev56-dec-osf4.0d) compiled by GNU C version 2.8.1.
   /usr/local/apps/gcc-2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/../../../../include/g++-3/stl_alloc.h: In function `static char * __default_alloc_template<false,0>::_S_chunk_alloc(long unsigned int, int &)':
   /usr/local/apps/gcc-2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/../../../../include/g++-3/stl_alloc.h:531:   instantiated from `__default_alloc_template<false,0>::_S_refill(long unsigned int)'
   /usr/local/apps/gcc-2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/../../../../include/g++-3/stl_alloc.h:419:   instantiated from here
   /usr/local/apps/gcc-2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/../../../../include/g++-3/stl_alloc.h:487: warning: cast increases required alignment of target type
   /usr/local/apps/gcc-2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/../../../../include/g++-3/stl_alloc.h:488: warning: cast increases required alignment of target type
   /usr/local/apps/gcc-2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/../../../../include/g++-3/stl_alloc.h: In function `static void * __default_alloc_template<false,0>::_S_refill(long unsigned int)':
   /usr/local/apps/gcc-2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/../../../../include/g++-3/stl_alloc.h:419:   instantiated from here
   /usr/local/apps/gcc-2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/../../../../include/g++-3/stl_alloc.h:542: warning: cast increases required alignment of target type
   /usr/local/apps/gcc-2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/../../../../include/g++-3/stl_alloc.h:543: warning: cast increases required alignment of target type
   /usr/local/apps/gcc-2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/../../../../include/g++-3/stl_alloc.h:546: warning: cast increases required alignment of target type
    as -g -nocpp -O0 -o alpha.warn.o alpha.warn.s
    /usr/local/apps/gcc-2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/mips-tfile -v -I alpha.warn.o~ -o alpha.warn.o alpha.warn.s
   mips-tfile version 2.95.2 19991024 (release)
   %

Compiling the same file with an i586-pc-linux-gnu gcc 2.95.2 and STL
produces no warnings.

I don't know whether this is an actual alignment problem in the STL,
or "just" a spurious warning, but either way, it seems to me that it
qualifies as a (minor) bug: <vector> is shipped as part of a gcc release,
and IMHO it should be warning-free under "reasonable" warning options
like -Wcast-align.  (Or if the warning is genuine but harmless, perhaps
this should be documented?)

Along with this message, I am MIME-attaching the files

   alpha.warn.cc		C++ cource code file shown above
   alpha.warn.script		script(1) transcript shown above
   alpha.warn.ii.bz2		cpp output from above run (compressed)

-- 
-- Jonathan Thornburg <jthorn@thp.univie.ac.at>
   http://www.thp.univie.ac.at/~jthorn/home.html
   Universitaet Wien (Vienna, Austria) / Institut fuer Theoretische Physik
   "C++ is to programming as sex is to reproduction. Better ways might
    technically exist but they're not nearly as much fun." -- Nikolai Irgens
#include <vector>
using namespace std;

class	gridfn_vector
	{
public:
	gridfn_vector()
		: N_gridfns_(0),
		  gfns_(0)
		{ }
	~gridfn_vector()
		{ }

private:
	// we forbid copying and passing by value
	// by declaring the copy constructor and assignment operator
	// private, but never defining them
	gridfn_vector(const gridfn_vector &rhs);
	gridfn_vector& operator=(const gridfn_vector &rhs);

private:
	int N_gridfns_;
	vector<int> gfns_;
	};
Script started on Tue Aug 29 13:12:16 2000
% /usr/local/apps/gcc-2.95.2/bin/g++ --verbose --save-temps -Wcast-align -c alph a.warn.cc
Reading specs from /usr/local/apps/gcc-2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/specs
gcc version 2.95.2 19991024 (release)
 /usr/local/apps/gcc-2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/cpp -lang-c++ -v -D__GNUC__=2 -D__GNUG__=2 -D__GNUC_MINOR__=95 -D__cplusplus -Dunix -D__osf__ -D_LONGLONG -DSYSTYPE_BSD -D_SYSTYPE_BSD -D__unix__ -D__osf__ -D_LONGLONG -D__SYSTYPE_BSD__ -D_SYSTYPE_BSD -D__unix -D__SYSTYPE_BSD -Asystem(unix) -Asystem(xpg4) -D__EXCEPTIONS -Wcast-align -D__LANGUAGE_C_PLUS_PLUS__ -D__LANGUAGE_C_PLUS_PLUS -D__cplusplus -Acpu(alpha) -Amachine(alpha) -D__alpha -D__alpha__ -D__alpha_ev5__ -Acpu(ev5) -D__alpha_bwx__ -Acpu(bwx) alpha.warn.cc alpha.warn.ii
GNU CPP version 2.95.2 19991024 (release)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/apps/gcc-2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/../../../../include/g++-3
 /usr/local/include
 /usr/local/apps/gcc-2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/../../../../alphaev56-dec-osf4.0d/include
 /usr/local/apps/gcc-2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/include
 /usr/include
End of search list.
The following default directories have been omitted from the search path:
End of omitted list.
 /usr/local/apps/gcc-2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/cc1plus alpha.warn.ii -quiet -dumpbase alpha.warn.cc -Wcast-align -version -o alpha.warn.s
GNU C++ version 2.95.2 19991024 (release) (alphaev56-dec-osf4.0d) compiled by GNU C version 2.8.1.
/usr/local/apps/gcc-2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/../../../../include/g++-3/stl_alloc.h: In function `static char * __default_alloc_template<false,0>::_S_chunk_alloc(long unsigned int, int &)':
/usr/local/apps/gcc-2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/../../../../include/g++-3/stl_alloc.h:531:   instantiated from `__default_alloc_template<false,0>::_S_refill(long unsigned int)'
/usr/local/apps/gcc-2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/../../../../include/g++-3/stl_alloc.h:419:   instantiated from here
/usr/local/apps/gcc-2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/../../../../include/g++-3/stl_alloc.h:487: warning: cast increases required alignment of target type
/usr/local/apps/gcc-2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/../../../../include/g++-3/stl_alloc.h:488: warning: cast increases required alignment of target type
/usr/local/apps/gcc-2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/../../../../include/g++-3/stl_alloc.h: In function `static void * __default_alloc_template<false,0>::_S_refill(long unsigned int)':
/usr/local/apps/gcc-2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/../../../../include/g++-3/stl_alloc.h:419:   instantiated from here
/usr/local/apps/gcc-2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/../../../../include/g++-3/stl_alloc.h:542: warning: cast increases required alignment of target type
/usr/local/apps/gcc-2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/../../../../include/g++-3/stl_alloc.h:543: warning: cast increases required alignment of target type
/usr/local/apps/gcc-2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/../../../../include/g++-3/stl_alloc.h:546: warning: cast increases required alignment of target type
 as -g -nocpp -O0 -o alpha.warn.o alpha.warn.s
 /usr/local/apps/gcc-2.95.2/lib/gcc-lib/alphaev56-dec-osf4.0d/2.95.2/mips-tfile -v -I alpha.warn.o~ -o alpha.warn.o alpha.warn.s
mips-tfile version 2.95.2 19991024 (release)
% exit
exit

script done on Tue Aug 29 13:12:23 2000

alpha.warn.ii.bz2


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