conti@jupiter.zir.ethz.ch (07/25/89)
>From jupiter.zir.ethz.ch!conti Tue Jul 25 12:17:05 MET 1989 remote from ethz Michael, I've tried to compile a large program I had developed with ATT CC 1.2 with g++ 1.35 on a sun3-os4, and I have run into what I suppose to be 3 compiler bugs. 1. User-defined implicit conversions are not always performed as described in Stroustrup, r.9.3. When compiled with g++ -v, the following example produces the following error message: ------------- example------------ class C { unsigned i; public: operator unsigned(){return i;} }; void main () { C c; if (c) { } } ------------------ error message ------------------------------- g++ version 1.35.1- /usr/local/lib/gcc-cpp -+ -v -undef -D__GNU__ -D__GNUG__ -D__cplusplus -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -D__HAVE_68881__ -Dmc68020 test.C /tmp/cca03895.cpp GNU CPP version 1.35 /usr/local/lib/gcc-cc1plus /tmp/cca03895.cpp -quiet -dumpbase test.C -noreg -version -o /tmp/cca03895.s GNU C++ version 1.35.1- (68k, MIT syntax) compiled by GNU C version 1.35. In function void main (): test.C:10: type conversion required for type `C' 2. Declaration of 2-dimensional arrays of class objects with a class constructor cause a compiler crash. ------------------- example ------------------------ class C { int i; public: C () {} }; void main () { C c[3][4]; } ------------------ error message ------------------------ g++ version 1.35.1- /usr/local/lib/gcc-cpp -+ -v -undef -D__GNU__ -D__GNUG__ -D__cplusplus -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -D__HAVE_68881__ -Dmc68020 test.C /tmp/cca03904.cpp GNU CPP version 1.35 /usr/local/lib/gcc-cc1plus /tmp/cca03904.cpp -quiet -dumpbase test.C -noreg -version -o /tmp/cca03904.s GNU C++ version 1.35.1- (68k, MIT syntax) compiled by GNU C version 1.35. In function void main (): test.C:9: Segmentation violation g++: Program cc1plus got fatal signal 11. 3. Formal arguments declared as constant arrays of class pointers are not handled properly. In the following example, the array of pointers to integers is accepted as actual parameter (as I expected it to be), while the array of pointers to class objects is not. A workaround for my code is to define the array of pointers via a typedef. --------------------- example ------------------------------- class C { int i; }; void f (const C* cp[3]) {} void g (const int* ip[3]) {} void main () { C* cp[3]; int* ip[3]; f (cp); g (ip); } ---------------------- error message ------------------------ g++ version 1.35.1- /usr/local/lib/gcc-cpp -+ -v -undef -D__GNU__ -D__GNUG__ -D__cplusplus -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -D__HAVE_68881__ -Dmc68020 test.C /tmp/cca03910.cpp GNU CPP version 1.35 /usr/local/lib/gcc-cc1plus /tmp/cca03910.cpp -quiet -dumpbase test.C -noreg -version -o /tmp/cca03910.s GNU C++ version 1.35.1- (68k, MIT syntax) compiled by GNU C version 1.35. In function void main (): test.C:13: argument passing between incompatible pointer types __paolo --------------------- Paolo Conti Integrated Systems Lab Swiss federal Institute of Technology ETH-Zentrum 8092 Zuerich (Switzerland) conti@iis.ethz.ch conti@iis.uucp conti@czheth5a.bitnet