🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #333

Bug in g++ 1.35.0: Generates incorrect code for references.

#333
From: Per Abrahamsen
Date: Sat, 05 Aug 1989 02:54
58 lines
2126 bytes
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
Technical Details
Message-ID: <8908050254.AA00399@iesd.dk>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!iuvax!cica!tut.cis.ohio-state.edu!IESD.AUC.DK!amanda

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!iuvax!cica!tut.cis.ohio-state.edu!IESD.AUC.DK!amanda
From: amanda@IESD.AUC.DK (Per Abrahamsen)
Newsgroups: gnu.g++.bug
Subject: Bug in g++ 1.35.0: Generates incorrect code for references.
Message-ID: <8908050254.AA00399@iesd.dk>
Date: 5 Aug 89 02:54:35 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 58