Article View: gnu.g++.bug
Article #1852g++ bugs
From: Stephen Ng
Date: Tue, 11 Apr 1989 14:33
Date: Tue, 11 Apr 1989 14:33
58 lines
1686 bytes
1686 bytes
Hi, I've just tried porting over a large number of files from cfront to g++.
I'm using g++ 1.34.0. Here are two of the problems I found:
1) Description: g++ doesn't implicitly cast between fundamental types if the
return value of a member function is a reference which is immediately used as an
argument for another function.
Example:
char &ref_return();
class c
{
public:
int_arg(int i);
};
void foo()
{
c c1;
c1.int_arg(ref_return());
}
works in cfront, but produces "bad argument 0 for function 'c::int_arg (int)'
(type was char &)
Workaround:
Assign the return value to a temporary variable and use the temporary as the
function argument.
2) Description: g++ doesn't initialize by assignment for a class if the class
a) has no constructor explicitly declared and b) if the class has a member class
which has a constructor.
Example:
class Member {
public:
Member();
};
class Foo {
Member mem;
};
void func()
{
Foo f1;
Foo f2 = f1;
}
This passes through cfront properly, but generates a "unexpected argument to
constructor 'Foo'" error in g++.
Workaround:
explicitly declare a constructor for class Foo.
Thanks,
Steve
Technical Details
Message-ID:
<8904111433.AA00725@lotus.lotus.com>Path:
arc1-ca.pugleaf.net!utzoo!telly!attcan!dptcdc!jarvis.csri.toronto.edu!mailrus!ukma!tut.cis.ohio-state.edu!GARP.MIT.EDU!lotus!stevengShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!attcan!dptcdc!jarvis.csri.toronto.edu!mailrus!ukma!tut.cis.ohio-state.edu!GARP.MIT.EDU!lotus!steveng From: lotus!steveng@GARP.MIT.EDU (Stephen Ng) Newsgroups: gnu.g++.bug Subject: g++ bugs Message-ID: <8904111433.AA00725@lotus.lotus.com> Date: 11 Apr 89 14:33:22 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 58