Article View: gnu.g++.bug
Article #1715BUG(S) in G++ 1.34.0 - overloaded methods
From: 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
Technical Details
Message-ID:
<8903100102.AA03725@riunite.aca.mcc.com>Path:
arc1-ca.pugleaf.net!utzoo!telly!attcan!dptcdc!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!MCC.COM!rfgShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!attcan!dptcdc!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!MCC.COM!rfg From: rfg@MCC.COM (Ron Guilmette) Newsgroups: gnu.g++.bug Subject: BUG(S) in G++ 1.34.0 - overloaded methods Message-ID: <8903100102.AA03725@riunite.aca.mcc.com> Date: 10 Mar 89 01:02:16 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 71