This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]