Article View: gnu.g++.bug
Article #1517possible g++ bug
From: Dan DuVarney
Date: Tue, 01 Nov 1988 03:44
Date: Tue, 01 Nov 1988 03:44
34 lines
1246 bytes
1246 bytes
I am using g++ version 1.25 on a Sun 3/50 running SunOS 3.5.
It appears that g++ is incorrectly choosing which constructor
to use in certain cases. For example:
--------------------------------------------------
#include "stream.h"
class F {
int i;
float f;
public:
F(int i1, float f1);
F(int i1, int i2);
}
F::F(int i1, float f1)
{ i = i1; f = f1; cout << "int, float constructor called\n"; }
F::F(int i1, int i2)
{ i = i1 + i2; f = 0.0; cout << "int, int constructor called\n"; }
main()
{
F f(0,0.0);
}
----------------------------------------------------
When I run this program the output is "int, int constructor called."
It seems to me that the int, float constructor should be called
instead -- although I am a C++ novice and could be wrong.
--
Dan DuVarney ...!mcnc!rti!dg-rtp!duvarney
Technical Details
Message-ID:
<1609@xyzzy.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!uunet!tut.cis.ohio-state.edu!mailrus!rutgers!labrea!mcnc!rti!xyzzy!duvarneyShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!uunet!tut.cis.ohio-state.edu!mailrus!rutgers!labrea!mcnc!rti!xyzzy!duvarney From: duvarney@xyzzy.UUCP (Dan DuVarney) Newsgroups: gnu.g++.bug Subject: possible g++ bug Message-ID: <1609@xyzzy.UUCP> Date: 1 Nov 88 03:44:03 GMT Reply-To: duvarney@.UUCP () Distribution: gnu Organization: Data General Corporation, Research Triangle Park, NC Lines: 33