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]

the attached C++ snippet compiles with -g and -O3 but not with -O or -O2


file attached oof.ii.bz2
compiler command : gcc -v -save-temps -c oof.cc; gcc -v -save-temps -c 
-O oof.cc
Output of the compiler:
Reading specs from /usr/lib/gcc-lib/i686-redhat-linux/3.0.1/specs
Configured with: ../configure --prefix=/usr --enable-shared 
--enable-threads --disable-nls i686-redhat-linux
Thread model: posix
gcc version 3.0.1
 /usr/lib/gcc-lib/i686-redhat-linux/3.0.1/cpp0 -lang-c++ -D__GNUG__=3 
-D__GXX_DEPRECATED -D__EXCEPTIONS -D__GXX_ABI_VERSION=100 -v 
-D__GNUC__=3 -D__GNUC_MINOR__=0 -D__GNUC_PATCHLEVEL__=1 -D__ELF__ -Dunix 
-Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux 
-Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -D_GNU_SOURCE 
-Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ 
-D__tune_pentiumpro__ oof.cc oof.ii
GNU CPP version 3.0.1 (cpplib) (i386 Linux/ELF)
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/usr/i686-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/g++-v3
 /usr/include/g++-v3/i686-redhat-linux
 /usr/include/g++-v3/backward
 /usr/lib/gcc-lib/i686-redhat-linux/3.0.1/include
 /usr/include
End of search list.
 /usr/lib/gcc-lib/i686-redhat-linux/3.0.1/cc1plus -fpreprocessed oof.ii 
-quiet -
dumpbase oof.cc -version -o oof.s
GNU CPP version 3.0.1 (cpplib) (i386 Linux/ELF)
GNU C++ version 3.0.1 (i686-redhat-linux)
        compiled by GNU C version 3.0.1.
In file included from Oof.h:4,
                 from oof.cc:1:
SmartPointer.h:18: warning: friend declaration `bool operator==(const
   SmartPointer<Type>&, const SmartPointer<Type>&)' declares a non-template
   function
SmartPointer.h:18: warning: (if this is not what you intended, make sure 
the
   function template has already been declared and add <> after the 
function
   name here) -Wno-non-template-friend disables this warning.
 as --traditional-format -V -Qy -o oof.o oof.s
GNU assembler version 2.10.91 (i386-redhat-linux) using BFD version 
2.10.91.0.2

The error when trying to compile this with g++ -O or g++ -O2 is
In file included from Oof.h:4,
                 from oof.cc:1:
SmartPointer.h:18: warning: friend declaration `bool operator==(const
   SmartPointer<Type>&, const SmartPointer<Type>&)' declares a non-template
   function
SmartPointer.h:18: warning: (if this is not what you intended, make sure 
the
   function template has already been declared and add <> after the 
function
   name here) -Wno-non-template-friend disables this warning.
SmartPointer.h: In function `std::basic_ostream<char, 
std::char_traits<char> >&
   operator<<(std::basic_ostream<char, std::char_traits<char> >&, const
   SmartPointer<String>&)':
oof.cc:9:   instantiated from here
SmartPointer.h:120: no match for `std::basic_ostream<char,
   std::char_traits<char> >& << Counted<String>&' operator
/usr/include/g++-v3/bits/ostream.tcc:50: candidates are:
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(std::basic_ostream<_CharT,
   _Traits>&(*)(std::basic_ostream<_CharT, _Traits>&)) [with _CharT = char,
   _Traits = std::char_traits<char>]
/usr/include/g++-v3/bits/ostream.tcc:72:                
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(std::basic_ios<_CharT,
   _Traits>&(*)(std::basic_ios<_CharT, _Traits>&)) [with _CharT = char, 
_Traits
   = std::char_traits<char>]
/usr/include/g++-v3/bits/ostream.tcc:94:                
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(std::ios_base&(*)(std::ios_base&)) [with _CharT 
= char,
   _Traits = std::char_traits<char>]
/usr/include/g++-v3/bits/ostream.tcc:140:                
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(long int) [with _CharT = char, _Traits =
   std::char_traits<char>]
/usr/include/g++-v3/bits/ostream.tcc:177:                
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(long unsigned int) [with _CharT = char, _Traits =
   std::char_traits<char>]
/usr/include/g++-v3/bits/ostream.tcc:115:                
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(bool) [with _CharT = char, _Traits =
   std::char_traits<char>]
/usr/include/g++-v3/bits/std_ostream.h:99:                
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(short int) [with _CharT = char, _Traits =
   std::char_traits<char>]
/usr/include/g++-v3/bits/std_ostream.h:110:                
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(short unsigned int) [with _CharT = char, _Traits =
   std::char_traits<char>]
/usr/include/g++-v3/bits/std_ostream.h:114:                
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(int) [with _CharT = char, _Traits =
   std::char_traits<char>]
/usr/include/g++-v3/bits/std_ostream.h:125:                
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(unsigned int) [with _CharT = char, _Traits =
   std::char_traits<char>]
/usr/include/g++-v3/bits/ostream.tcc:203:                
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(long long int) [with _CharT = char, _Traits =
   std::char_traits<char>]
/usr/include/g++-v3/bits/ostream.tcc:241:                
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(long long unsigned int) [with _CharT = char, 
_Traits =
   std::char_traits<char>]
/usr/include/g++-v3/bits/ostream.tcc:267:                
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(double) [with _CharT = char, _Traits =
   std::char_traits<char>]
/usr/include/g++-v3/bits/std_ostream.h:140:                
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(float) [with _CharT = char, _Traits =
   std::char_traits<char>]
/usr/include/g++-v3/bits/ostream.tcc:292:                
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(long double) [with _CharT = char, _Traits =
   std::char_traits<char>]
/usr/include/g++-v3/bits/ostream.tcc:317:                
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(const void*) [with _CharT = char, _Traits =
   std::char_traits<char>]
/usr/include/g++-v3/bits/ostream.tcc:342:                
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(std::basic_streambuf<_CharT, _Traits>*) [with 
_CharT =
   char, _Traits = std::char_traits<char>]
SmartPointer.h:120:                 std::basic_ostream<char,
   std::char_traits<char> >& operator<<(std::basic_ostream<char,
   std::char_traits<char> >&, const SmartPointer<String>&)
SmartPointer.h:120:                 std::basic_ostream<char,
   std::char_traits<char> >& operator<<(std::basic_ostream<char,
   std::char_traits<char> >&, const SmartPointer<StringPointerVector>&)
SmartPointer.h:20:                 std::basic_ostream<char,
   std::char_traits<char> >& operator<<(std::basic_ostream<char,
   std::char_traits<char> >&, const Counted<StringPointerVector>&)
/usr/include/g++-v3/bits/std_ostream.h:255:                
   std::basic_ostream<char, _Traits>& 
std::operator<<(std::basic_ostream<char,
   _Traits>&, const unsigned char*) [with _Traits = std::char_traits<char>]
/usr/include/g++-v3/bits/std_ostream.h:250:                
   std::basic_ostream<char, _Traits>& 
std::operator<<(std::basic_ostream<char,
   _Traits>&, const signed char*) [with _Traits = std::char_traits<char>]
/usr/include/g++-v3/bits/ostream.tcc:689:                
   std::basic_ostream<char, _Traits>& 
std::operator<<(std::basic_ostream<char,
   _Traits>&, const char*) [with _Traits = std::char_traits<char>]
/usr/include/g++-v3/bits/ostream.tcc:643:                
   std::basic_ostream<_CharT, _Traits>&
   std::operator<<(std::basic_ostream<_CharT, _Traits>&, const char*) [with
   _CharT = char, _Traits = std::char_traits<char>]
/usr/include/g++-v3/bits/std_ostream.h:231:                
   std::basic_ostream<char, _Traits>& 
std::operator<<(std::basic_ostream<char,
   _Traits>&, unsigned char) [with _Traits = std::char_traits<char>]
/usr/include/g++-v3/bits/std_ostream.h:226:                
   std::basic_ostream<char, _Traits>& 
std::operator<<(std::basic_ostream<char,
   _Traits>&, signed char) [with _Traits = std::char_traits<char>]
/usr/include/g++-v3/bits/ostream.tcc:575:                
   std::basic_ostream<char, _Traits>& 
std::operator<<(std::basic_ostream<char,
   _Traits>&, char) [with _Traits = std::char_traits<char>]
/usr/include/g++-v3/bits/std_ostream.h:215:                
   std::basic_ostream<_CharT, _Traits>&
   std::operator<<(std::basic_ostream<_CharT, _Traits>&, char) [with 
_CharT =
   char, _Traits = std::char_traits<char>]



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