This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Passing temprary by reference requires copy constructor in 3.4?
- From: Peter Cech <pcech at vision dot ee dot ethz dot ch>
- To: gcc at gcc dot gnu dot org
- Date: Fri, 26 Nov 2004 20:10:40 +0100
- Subject: Passing temprary by reference requires copy constructor in 3.4?
Hi,
trying to compile
class EventObject
{
public:
EventObject() {}
private:
EventObject(const EventObject&);
};
class AnyEvent : public EventObject
{
public:
AnyEvent() {}
private:
AnyEvent(const AnyEvent&);
};
void invoke(const EventObject &) {}
void caller1()
{
AnyEvent event;
invoke(event);
}
void caller2()
{
invoke(AnyEvent());
}
leads to following error with both gcc (GCC) 3.4.3 (Gentoo Linux 3.4.3,
ssp-3.4.3-0, pie-8.7.6.6) and gcc (GCC) 4.0.0 20041121 (experimental)
a.cpp: In function `void caller2()':
a.cpp:16: error: `AnyEvent::AnyEvent(const AnyEvent&)' is private
a.cpp:29: error: within this context
Why gcc requires copy constructor in such situation?
Regards,
Peter Cech