amanda@IESD.AUC.DK (Per Abrahamsen) (08/05/89)
System: g++ 1.35.0 on a Sun3/60 with 8Mb RAM running SunOS 4.0.1. I do not understand the semantics of references, but I believe the following code should be correct, since BS uses it as an example in the bible. It also works under cfront 1.2. Script started on Sat Aug 5 04:33:29 1989 $ cat err7.cc #include <stream.h> #ifndef __GNUG__ enum bool { FALSE, TRUE }; #endif struct coor { short x; short y; inline bool operator!=(const coor& pos) { return x != pos.x || y != pos.y; } inline const coor& operator=(const coor& pos) { x = pos.x; y = pos.y; return pos; } inline coor(int x, int y) { coor::x = x; coor::y = y; } inline coor(const coor& pos) { x = pos.x; y = pos.y; } inline coor() { x = y = 0; } }; int main() { coor pos; cout << "A\n"; if((pos = coor(0, 0)) != coor(-32001, -32001)) // G++ BUG! cout << "B\n"; return 0; } $ g++ -v -g err7.cc g++ version 1.35.0 /home/local/gnu/lib/gcc-cpp -+ -v -undef -D__GNU__ -D__GNUG__ -D__cplusplus -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -D__HAVE_68881__ -Dmc68020 err7.cc /tmp/cca14642.cpp GNU CPP version 1.35 /home/local/gnu/lib/gcc-cc1plus /tmp/cca14642.cpp -quiet -dumpbase err7.cc -noreg -version -G -o /tmp/cca14642.s GNU C++ version 1.35.0 (68k, MIT syntax) compiled by GNU C version 1.35. as -mc68020 /tmp/cca14642.s -o err7.o /home/local/gnu/lib/gcc-ld++ -C -dc -dp -Bstatic /home/local/gnu/lib/crt0+.o /lib/Mcrt1.o err7.o -lg++ /home/local/gnu/lib/gcc-gnulib -lg -lc $ a.out A Memory fault - core dumped $ script done on Sat Aug 5 04:34:13 1989 -- Per Abrahamsen, amanda@iesd.dk, {...}!mcvax!diku!iesd!amanda