schmidt%siam.ics.uci.edu@ORION.CF.UCI.EDU ("Douglas C. Schmidt") (10/01/88)
Hi, G++ 1.27 gets a segmentation violation for the following file. This file compiles and executes correctly with AT&T CC 1.2, producing an output of foo101 I think g++ is having problems with typedefs and classes. Here's the code: ---------------------------------------- #include <stream.h> /**********************************************************************/ typedef class Machine { private: char *Machine_Name; double Clock_Speed; BOOLEAN Float_Chip; public: Machine(char *Name,double Clock_Speed,BOOLEAN FPC): Machine_Name(Name),Clock_Speed(Clock_Speed),Float_Chip(FPC) { } char *Name(void) { return(Machine_Name); } double Return_Clock_Speed(void) { return(Clock_Speed); } BOOLEAN Has_Float_Chip(void) { return(Float_Chip); } virtual char *CPU_Type() { return("No default"); } } MACHINE, *MACHINE_PTR; main(int,char *argv[]) { MACHINE_PTR Foo = new MACHINE("foo",10.0,TRUE); cout << Foo->Name() << Foo->Return_Clock_Speed() << Foo->Has_Float_Chip() << "\n"; } ---------------------------------------- Here's the diagnostic: Script started on Fri Sep 30 15:13:35 1988 [~/c++ ] [/cd/ua/schmidt/c++] ..: g++ -v bug.C g++ version 1.27.0 echo use .cc filename extension! use .cc filename extension! /usr/public/lib/g++/gcc-cpp+ -v -I/cd/ua/schmidt/include/ -undef -D__GNU__ -D__GNUG__ -Dsparc -Dsun -Dunix bug.C /tmp/cca02014.cpp GNU CPP version 1.27.0 /usr/public/lib/g++/gcc-c++ /tmp/cca02014.cpp -quiet -dumpbase bug.C -fchar-charconst -noreg -version -o /tmp/cca02014.s GNU C++ version 1.27.0 (sparc) compiled by GNU C version 1.28. bug.C:37: Segmentation violation /usr/public/g++: Program c++ got fatal signal 11. script done on Fri Sep 30 15:16:31 1988