🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Subclassing bug in G++ 1.33

#1709
From: "Robert S. French"
Date: Sat, 25 Feb 1989 04:04
49 lines
1605 bytes
There is an odd bug in G++ 1.33 which occurs when a pointer to a
subclass member is passed to a function of the superclass by
reference.  In other words:

class foo {
    int x;
public:
    broken(foo*&);
};

class bar : foo {
    int y;
};

working(foo*&)
{
}

baz()
{
    foo *inst = new foo;
    foo a1;
    bar b1;

    working(&a1);
    working(&b1);
    inst->broken(&a1);
    inst->broken(&b1); // This line will fail
}

The first three calls in baz() will succeed.  The second fails.
Here are the diagnostics:

g++ version 1.33.0
 /mit/gnu/vaxlib/gcc-cpp -+ -v -undef -D__GNU__ -D__GNUG__ -Dvax -Dunix -D__vax__ -D__unix__ foo.c /tmp/cc008347.cpp
GNU CPP version 1.33
 /mit/gnu/vaxlib/gcc-c++ /tmp/cc008347.cpp -quiet -dumpbase foo.c -version -o /tmp/cc008347.s
GNU C++ version 1.33.0 (vax) compiled by GNU C version 1.33.
In function baz ():
foo.c:24: bad argument 0 for function `foo::broken (struct foo *&)' (type was struct foo *)

The program works fine if broken is defined as broken(foo*) or
broken(foo&) and baz() is changed accordingly.  The bug only shows
itself when pointers are passed by reference.

(Some code in InterViews 2.4 tickled this bug)

		Rob French
Technical Details
Message-ID: <8902250404.AA08350@OLIVER.MIT.EDU>
Path: arc1-ca.pugleaf.net!utzoo!telly!attcan!uunet!tut.cis.ohio-state.edu!ATHENA.MIT.EDU!rfrench

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!attcan!uunet!tut.cis.ohio-state.edu!ATHENA.MIT.EDU!rfrench
From: rfrench@ATHENA.MIT.EDU ("Robert S. French")
Newsgroups: gnu.g++.bug
Subject: Subclassing bug in G++ 1.33
Message-ID: <8902250404.AA08350@OLIVER.MIT.EDU>
Date: 25 Feb 89 04:04:43 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 49