This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++ templates
- From: Waller Fred <fred dot waller at tekla dot com>
- To: "'gcc-bugs at gcc dot gnu dot org'" <gcc-bugs at gcc dot gnu dot org>
- Date: Tue, 4 Jun 2002 15:22:19 +0300
- Subject: c++ templates
Strange things for someone like me trying to imitate the big guys playing
with templates
fw_debian% gcc -v -Wall -o tempf2 tempf2.cc
Reading specs from /usr/lib/gcc-lib/i386-linux/2.95.4/specs
gcc version 2.95.4 20011002 (Debian prerelease)
/usr/lib/gcc-lib/i386-linux/2.95.4/cpp0 -lang-c++ -v -D__GNUC__=2
-D__GNUG__=2 -D__GNUC_MINOR__=95 -D__cplusplus -D__ELF__ -Dunix -D__i386__
-Dlinux -D__ELF__ -D__unix__ -D__i386__ -D__linux__ -D__unix -D__linux
-Asystem(posix) -D__EXCEPTIONS -Wall -Acpu(i386) -Amachine(i386) -Di386
-D__i386 -D__i386__ tempf2.cc /tmp/ccDcVyC4.ii
GNU CPP version 2.95.4 20011002 (Debian prerelease) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc-lib/i386-linux/2.95.4/../../../../include/g++-3
/usr/local/include
/usr/lib/gcc-lib/i386-linux/2.95.4/include
/usr/include
End of search list.
The following default directories have been omitted from the search path:
/usr/lib/gcc-lib/i386-linux/2.95.4/../../../../i386-linux/include
End of omitted list.
/usr/lib/gcc-lib/i386-linux/2.95.4/cc1plus /tmp/ccDcVyC4.ii -quiet
-dumpbase tempf2.cc -Wall -version -o /tmp/cc9m5Ypa.s
GNU C++ version 2.95.4 20011002 (Debian prerelease) (i386-linux) compiled by
GNU C version 2.95.4 20011002 (Debian prerelease).
tempf2.cc: In function `int main()':
tempf2.cc:26: Internal compiler error 71.
tempf2.cc:26: Please submit a full bug report.
tempf2.cc:26: Internal compiler error:
tempf2.cc:26: See <URL:http://www.gnu.org/software/gcc/bugs.html> for
instructions.
----------------------------------------------------------------------------
------
fw_debian% cat tempf2.cc
#include <stdio.h>
typedef double Bop_t (double a, double b);
inline double plus (double a, double b) {
return a+b;
}
template <typename Left_t, Bop_t Bop, typename Right_t>
struct Binop {
Left_t left;
Right_t right;
Binop (Left_t l, Right_t r) : left(l), right(r) {}
double operator () () {
return Bop(left(), right());
}
};
struct Atom {
double data;
double operator () () {return data;}
void pr() {printf ("%g\n", data);}
};
template<class T>
Binop<T, plus, Atom> plusf (T t, Atom a) {
return Binop<T, plus, Atom>(t,a);
}
int main() {
Atom aa = {4.};
Atom bb = {5.};
Atom cc = plusf(aa,bb);
aa.pr();
bb.pr();
cc.pr();
return 0;
}
----------------------------------------------------------------------------
----------------
gcc-3.0 does not seem to be quite properly installed:
fw_debian% gcc-3.0 -v -Wall -o tempf2 tempf2.cc
Reading specs from /usr/lib/gcc-lib/i386-linux/3.0.4/specs
Configured with: ../src/configure -v
--enable-languages=c,c++,java,f77,proto,objc --prefix=/usr
--infodir=/share/info --mandir=/share/man --enable-shared --with-gnu-as
--with-gnu-ld --with-system-zlib --enable-long-long --enable-nls
--without-included-gettext --disable-checking --enable-threads=posix
--enable-java-gc=boehm --with-cpp-install-dir=bin --enable-objc-gc
i386-linux
Thread model: posix
gcc version 3.0.4
cc1plus -v -D__GNUC__=3 -D__GNUC_MINOR__=0 -D__GNUC_PATCHLEVEL__=4
-D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux
-Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -Wall -D_GNU_SOURCE
-Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i386__
tempf2.cc -D__GNUG__=3 -D__GXX_DEPRECATED -D__EXCEPTIONS
-D__GXX_ABI_VERSION=100 -quiet -dumpbase tempf2.cc -Wall -version -o
/tmp/ccAI2uTH.s
gcc-3.0: installation problem, cannot exec `cc1plus': No such file or
directory
----------------------------------------------------------------------------
----------------
thanks in advance
yours
Fred Waller
phone
+358 9 8879442 Work
+358 505 966851 Mobile