Hello, I'm working on Dev-cpp this is the output : ******************************************************************************** Compiler: Default compiler Building Makefile: "C:\cygwin\tmp\Makefile.win" Executing make... make.exe -f "C:\cygwin\tmp\Makefile.win" all g++.exe -c toto.cc -o toto.o -I"C:/GTK/INCLUDE" -I"C:/GTK/INCLUDE/GTK-2.0" -I"C:/GTK/INCLUDE/GLIB-2.0" -I"C:/GTK/INCLUDE/PANGO-1.0" -I"C:/GTK/INCLUDE/ATK-1.0" -I"C:/GTK/INCLUDE/GTKGLEXT-1.0" -I"C:/GTK/LIB/GTK-2.0/INCLUDE" -I"C:/GTK/LIB/GLIB-2.0/INCLUDE" -I"C:/GTK/LIB/GTKGLEXT-1.0/INCLUDE" -I"C:/GTK/INCLUDE/LIBGLADE-2.0" -I"C:/GTK/INCLUDE/LIBXML2" -v -save-temps Using built-in specs. Target: mingw32 Configured with: ../gcc-4.1.2/configure --with-gcc --with-gnu-ld --with-gnu-as --host=mingw32 --target=mingw32 --prefix=C:/MinGW --enable-threads --disable-nls --enable-languages=c,c++ --disable-win32-registry --disable-shared --enable-fully-dynamic-string --disable-libstdcxx-pch Thread model: win32 gcc version 4.1.2 c:/dev-cpp/bin/../libexec/gcc/mingw32/4.1.2/cc1plus.exe -E -quiet -v -IC:/GTK/INCLUDE -IC:/GTK/INCLUDE/GTK-2.0 -IC:/GTK/INCLUDE/GLIB-2.0 -IC:/GTK/INCLUDE/PANGO-1.0 -IC:/GTK/INCLUDE/ATK-1.0 -IC:/GTK/INCLUDE/GTKGLEXT-1.0 -IC:/GTK/LIB/GTK-2.0/INCLUDE -IC:/GTK/LIB/GLIB-2.0/INCLUDE -IC:/GTK/LIB/GTKGLEXT-1.0/INCLUDE -IC:/GTK/INCLUDE/LIBGLADE-2.0 -IC:/GTK/INCLUDE/LIBXML2 -iprefix c:\dev-cpp\bin\../lib/gcc/mingw32/4.1.2/ toto.cc -fpch-preprocess -o toto.ii ignoring nonexistent directory "c:/dev-cpp/bin/../lib/gcc/mingw32/4.1.2/../../../../include/c++/4.1.2" ignoring nonexistent directory "c:/dev-cpp/bin/../lib/gcc/mingw32/4.1.2/../../../../include/c++/4.1.2/mingw32" ignoring nonexistent directory "c:/dev-cpp/bin/../lib/gcc/mingw32/4.1.2/../../../../include/c++/4.1.2/backward" ignoring nonexistent directory "c:/dev-cpp/bin/../lib/gcc/mingw32/4.1.2/../../../../mingw32/include" ignoring nonexistent directory "C:/MinGW/lib/gcc/mingw32/../../../include/c++/4.1.2" ignoring nonexistent directory "C:/MinGW/lib/gcc/mingw32/../../../include/c++/4.1.2/mingw32" ignoring nonexistent directory "C:/MinGW/lib/gcc/mingw32/../../../include/c++/4.1.2/backward" ignoring nonexistent directory "C:/MinGW/lib/gcc/mingw32/4.1.2/include" ignoring nonexistent directory "C:/MinGW/lib/gcc/mingw32/../../../mingw32/include" #include "..." search starts here: #include <...> search starts here: C:/GTK/INCLUDE C:/GTK/INCLUDE/GTK-2.0 C:/GTK/INCLUDE/GLIB-2.0 C:/GTK/INCLUDE/PANGO-1.0 C:/GTK/INCLUDE/ATK-1.0 C:/GTK/INCLUDE/GTKGLEXT-1.0 C:/GTK/LIB/GTK-2.0/INCLUDE C:/GTK/LIB/GLIB-2.0/INCLUDE C:/GTK/LIB/GTKGLEXT-1.0/INCLUDE C:/GTK/INCLUDE/LIBGLADE-2.0 C:/GTK/INCLUDE/LIBXML2 c:/dev-cpp/bin/../lib/gcc/mingw32/4.1.2/../../../../include c:/dev-cpp/bin/../lib/gcc/mingw32/4.1.2/include C:/MinGW/lib/gcc/mingw32/../../../include C:/MinGW/include /mingw/include End of search list. c:/dev-cpp/bin/../libexec/gcc/mingw32/4.1.2/cc1plus.exe -fpreprocessed toto.ii -quiet -dumpbase toto.cc -auxbase-strip toto.o -version -o toto.s GNU C++ version 4.1.2 (mingw32) compiled by GNU C version 4.1.2. GGC heuristics: --param ggc-min-expand=99 --param ggc-min-heapsize=130982 Compiler executable checksum: 669e873dd1c794b0f5ddbea8fe211782 toto.cc:54: internal compiler error: in write_type, at cp/mangle.c:1651 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions. make.exe: *** [toto.o] Error 1 Execution terminated ******************************************************************************** the same error occurs on cygwin (v 3.4.4) and on latest ubuntu (v 4.2?) this is the code: ******************************************************************************** #include <complex> using namespace std; template <class T> class X { public: X() {} }; template <class T> class Y { public: template <class U> Y(const X<U>&) {} template <class U> Y& operator *=(const U&) { return *this; } }; template <class Tx, class Ty> Y<typeof(Tx()*Ty())> operator *(X<Tx>& x, const Ty& y) { Y<typeof(Tx()*Ty())> res(x); //res *= y; return res; } template <class Tx, class Ty> Y<typeof(Tx()*Ty())> operator *(const Tx& x, X<Ty>& y) { Y<typeof(Tx()*Ty())> res(y); //res *= x; return res; } int main() { double a; complex<double> b; X<double> i; X<complex<double> > j; i*a; a*i; i*b; b*i; j*a; a*j; j*b; b*j; } ******************************************************************************** It's my first bug report, How can I give you the .ii file?
Created attachment 14368 [details] source code I was playing a little with template
Created attachment 14369 [details] .ii file
I found this bug on a more complex program and I did an epurated code.
As far as I understand there is no way to encode currently typeof for templates.
yes, one of the way is to pass by an intermediate template type... (I found it on the web) but the compiler error could(and should) be fixed #define TPL_TYPEOF_MUL(A,B) typename typeof_mul<A,B>::type #define TYPEOF_MUL(A,B) typeof_mul<A,B>::type template <typename A, typename B> struct typeof_mul { typedef typeof(A()*B()) type; }; template <class Tx, class Ty> Y<TPL_TYPEOF_MUL(Tx,Ty)> operator *(X<Tx>& x, const Ty& y) { Y<TPL_TYPEOF_MUL(Tx,Ty)> res(x); //res *= y; return res; }
On the trunk we get: t.cc: In function 'Y<__typeof__ ((Tx() * Ty()))> operator*(X<Tx>&, const Ty&) [with Tx = double, Ty = double]': t.cc:29: sorry, unimplemented: mangling typeof, use decltype instead t.cc: In function 'int main()': t.cc:47: sorry, unimplemented: mangling typeof, use decltype instead t.cc:48: sorry, unimplemented: mangling typeof, use decltype instead t.cc:49: sorry, unimplemented: mangling typeof, use decltype instead t.cc:51: sorry, unimplemented: mangling typeof, use decltype instead t.cc:52: sorry, unimplemented: mangling typeof, use decltype instead t.cc:53: sorry, unimplemented: mangling typeof, use decltype instead t.cc:54: sorry, unimplemented: mangling typeof, use decltype instead So this is a dup of bug 11756. *** This bug has been marked as a duplicate of 11756 ***