public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Passing temprary by reference requires copy constructor in 3.4?
@ 2004-11-26 19:38 Peter Cech
  2004-11-26 19:48 ` Andrew Pinski
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Cech @ 2004-11-26 19:38 UTC (permalink / raw)
  To: gcc

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-11-27  8:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-26 19:38 Passing temprary by reference requires copy constructor in 3.4? Peter Cech
2004-11-26 19:48 ` Andrew Pinski
2004-11-26 20:10   ` Mikael Kilpeläinen
2004-11-26 21:36     ` Andrew Pinski
2004-11-26 21:41       ` Mikael Kilpeläinen
2004-11-27 18:16       ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).