Thread View: gnu.g++.bug
1 messages
1 total messages
Started by "Robert S. French"
Sat, 25 Feb 1989 04:04
Subclassing bug in G++ 1.33
Author: "Robert S. French"
Date: Sat, 25 Feb 1989 04:04
Date: Sat, 25 Feb 1989 04:04
49 lines
1605 bytes
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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads