This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
G++ bug in 971215: Extra temporary for method arguments
- To: egcs at cygnus dot com
- Subject: G++ bug in 971215: Extra temporary for method arguments
- From: chip at atlantic dot net
- Date: Fri, 26 Dec 1997 17:14:26 -0500 (EST)
- Reply-To: chip at pobox dot com
G++ in egcs-971217 creates an extra temporary for member function
arguments that are declared as a base value but are given a derived
value instead. What's really interesting is that this extra temporary
doesn't show up on regular functions calls, but only on member
function calls....
I'd look into it, but G++ is big and I haven't been into its guts in
years.... Any clues, oh G++ hackers?
Here's a test program that demonstrates the extra temporary:
-----------------------------------------------------------------------
#include <iostream>
class B {
public:
B() { cout << "B::B()" << endl; }
B(const B&) { cout << "B::B(const B&)" << endl; }
~B() { cout << "B::~B()" << endl; }
};
class D : public B {
public:
D() { cout << "D::D()" << endl; }
D(const D &d) : B(d) { cout << "D::D(const D&)" << endl; }
~D() { cout << "D::~D()" << endl; }
};
class Foo {
public:
void foo(B b) {}
};
int
main(int, char **)
{
D d;
Foo *f = new Foo;
f->foo(d);
}
-----------------------------------------------------------------------
--
Chip Salzenberg - a.k.a. - <chip@pobox.com>
"All you need is a toxic landfill /
A cycle and a sidecar and an urge to kill" // MST3K