1.1 guiding-decls inconsistency
Andrew Fitzgibbon
awf@robots.ox.ac.uk
Fri Nov 27 05:13:00 GMT 1998
The code below produces different results with/without -DTICKLE, under
-fguiding-decls.
#include <iostream.h>
template <class T> struct A;
template <class T>
struct A {
friend ostream& operator<<(ostream&, const A<T>&);
};
#ifdef TICKLE
A<bool> dummy;
#endif
void f(const A<bool>& a)
{
cout << a;
}
>From my reading of CD2, the friend should either declare the template or
not, it shouldn't depend on tickling. Without guiding-decls the behaviour
is the same, but at least it warns.
ia:cctests[1539]% egcs -v egcs-bugs.cc -DTICKLE
Reading specs from /homes/39/pkg/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.91.57/specs
gcc version egcs-2.91.57 19980901 (egcs-1.1 release)
/homes/39/pkg/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.91.57/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=91 -Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4 -D__sparc__ -D__sun__ -D__unix__ -D__svr4__ -D__SVR4 -D__sparc -D__sun -D__unix -Asystem(unix) -Asystem(svr4) -D__EXCEPTIONS -D__GCC_NEW_VARARGS__ -Acpu(sparc) -Amachine(sparc) -DTICKLE egcs-bugs.cc /var/tmp/ccT3y4HA.ii
GNU CPP version egcs-2.91.57 19980901 (egcs-1.1 release) (sparc)
#include "..." search starts here:
#include <...> search starts here:
/homes/39/pkg/include/g++
/homes/39/pkg/lib/g++-include
/usr/local/include
/homes/39/pkg/sparc-sun-solaris2.6/include
/homes/39/pkg/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.91.57/include
/usr/include
End of search list.
/homes/39/pkg/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.91.57/cc1plus /var/tmp/ccT3y4HA.ii -quiet -dumpbase egcs-bugs.cc -version -o /var/tmp/ccihD602.s
GNU C++ version egcs-2.91.57 19980901 (egcs-1.1 release) (sparc-sun-solaris2.6) compiled by GNU C version 2.7.2.3.
egcs-bugs.cc:17: warning: friend declaration `class ostream & operator <<(class ostream &, const struct A<T> &)'
egcs-bugs.cc:17: warning: declares a non-template function
egcs-bugs.cc:17: warning: (if this is not what you intended, make sure
egcs-bugs.cc:17: warning: the function template has already been declared,
egcs-bugs.cc:17: warning: and add <> after the function name here)
/usr/ccs/bin/as -V -Qy -s -o /var/tmp/ccNvWSrP.o /var/tmp/ccihD602.s
/usr/ccs/bin/as: WorkShop Compilers 4.X dev 18 Sep 1996
/homes/39/pkg/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.91.57/collect2 -V -Y P,/usr/ccs/lib:/usr/lib -Qy /homes/39/pkg/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.91.57/crt1.o /homes/39/pkg/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.91.57/crti.o /usr/ccs/lib/values-Xa.o /homes/39/pkg/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.91.57/crtbegin.o -L/homes/39/pkg/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.91.57 -L/homes/39/pkg/sparc-sun-solaris2.6/lib -L/usr/ccs/bin -L/usr/ccs/lib -L/homes/39/pkg/lib /var/tmp/ccNvWSrP.o -lstdc++ -lm -lgcc -lc -lgcc /homes/39/pkg/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.91.57/crtend.o /homes/39/pkg/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.91.57/crtn.o
ld: Software Generation Utilities - Solaris/ELF (3.0)
Undefined first referenced
symbol in file
operator<<(ostream &, A<bool> const &)/var/tmp/ccNvWSrP.o
main /homes/39/pkg/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.91.57/crt1.o
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status
volumnia:cctests[1540]% egcs egcs-bugs.cc
egcs-bugs.cc:17: warning: friend declaration `class ostream & operator <<(class ostream &, const struct A<T> &)'
egcs-bugs.cc:17: warning: declares a non-template function
egcs-bugs.cc:17: warning: (if this is not what you intended, make sure
egcs-bugs.cc:17: warning: the function template has already been declared,
egcs-bugs.cc:17: warning: and add <> after the function name here)
egcs-bugs.cc: In function `void f(const struct A<bool> &)':
egcs-bugs.cc:26: no match for `_IO_ostream_withassign & << const A<bool> &'
/homes/39/pkg/include/g++/iostream.h:77: candidates are: ostream::operator <<(char)
/homes/39/pkg/include/g++/iostream.h:78: ostream::operator <<(unsigned char)
/homes/39/pkg/include/g++/iostream.h:79: ostream::operator <<(signed char)
/homes/39/pkg/include/g++/iostream.h:80: ostream::operator <<(const char *)
/homes/39/pkg/include/g++/iostream.h:82: ostream::operator <<(const unsigned char *)
/homes/39/pkg/include/g++/iostream.h:84: ostream::operator <<(const signed char *)
/homes/39/pkg/include/g++/iostream.h:85: ostream::operator <<(const void *)
/homes/39/pkg/include/g++/iostream.h:86: ostream::operator <<(int)
/homes/39/pkg/include/g++/iostream.h:87: ostream::operator <<(unsigned int)
/homes/39/pkg/include/g++/iostream.h:88: ostream::operator <<(long int)
/homes/39/pkg/include/g++/iostream.h:89: ostream::operator <<(long unsigned int)
/homes/39/pkg/include/g++/iostream.h:91: ostream::operator <<(long long int)
/homes/39/pkg/include/g++/iostream.h:92: ostream::operator <<(long long unsigned int)
/homes/39/pkg/include/g++/iostream.h:94: ostream::operator <<(short int)
/homes/39/pkg/include/g++/iostream.h:95: ostream::operator <<(short unsigned int)
/homes/39/pkg/include/g++/iostream.h:97: ostream::operator <<(bool)
/homes/39/pkg/include/g++/iostream.h:99: ostream::operator <<(double)
/homes/39/pkg/include/g++/iostream.h:100: ostream::operator <<(float)
/homes/39/pkg/include/g++/iostream.h:104: ostream::operator <<(long double)
/homes/39/pkg/include/g++/iostream.h:106: ostream::operator <<(ostream & (*)(ostream &))
/homes/39/pkg/include/g++/iostream.h:107: ostream::operator <<(ios & (*)(ios &))
/homes/39/pkg/include/g++/iostream.h:108: ostream::operator <<(streambuf *)
More information about the Gcc-bugs
mailing list