Thread View: gnu.g++.bug
1 messages
1 total messages
Started by Ron Guilmette
Fri, 10 Mar 1989 01:02
BUG(S) in G++ 1.34.0 - overloaded methods
Author: Ron Guilmette
Date: Fri, 10 Mar 1989 01:02
Date: Fri, 10 Mar 1989 01:02
71 lines
2382 bytes
2382 bytes
The following short program demonstrates two bugs in g++ 1.34.0 on a Sun3.
First, it gets a compile time error (I think that it shouldn't). Second,
even after the error, a .s output file is left on disk (it should not be).
Following the program is a log of the compilation, assembly, linking,
and execution. Note that the error goes away if the first declaration
of a virtual function called foo (i.e. the one in class c1) is made
non-virtual (e.g. by commenting out the word virtual).
Cut here
--------------------------------------------------------------------------
/*
Description - check that calls to the correct overloaded virtual
function are generated even where the type of the formal
arguments for the overloadings are very similar or related.
*/
class c1 {
public:
virtual void foo (char)
{
printf ("FAILED - wrong overloaded virtual function called\n");
exit (0);
}
};
class c2 : c1 {
public:
virtual void foo (char)
{
printf ("FAILED - wrong overloaded virtual function called\n");
exit (0);
}
virtual void foo (char *)
{
printf ("PASSED\n");
}
};
void test ();
void main ()
{
test ();
exit (0);
}
char *message = "hello, world!";
void test ()
{
c2 c2_object;
c2_object.foo (message);
}
---------------------------------------------------------------------------
g++ -S -v x13.cc
g++ version 1.34.0.1
/usr/local/src/lib/1.34.0.1/sun3/gcc-cpp -+ -v -undef -D__GNU__ -D__GNUG__ -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -D__HAVE_68881__ -Dmc68020 x13.cc /tmp/cca03715.cpp
GNU CPP version 1.34.0.1
/usr/local/src/lib/1.34.0.1/sun3/gcc-c++ /tmp/cca03715.cpp -quiet -dumpbase x13.cc -noreg -version -o x13.s
GNU C++ version 1.34.0.1 (68k, MIT syntax) compiled by GNU C version 1.33.
x13.cc:26: conficting specification deriving virtual function `void c2::foo (char *)'
*** Error code 1 (ignored)
as x13.s -o x13.o
g++ x13.o -o x13
./x13
PASSED
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