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]

(3.4.2 Bug?) Copy ctor needed to pass temporary as const reference?


The following code does not compile with gcc 3.4.2 (OS is Redhat 7.2
on a 386, if it matters),

class NotCopyable {
public:
   NotCopyable();
private:
   NotCopyable(const NotCopyable&);
   NotCopyable& operator=(const NotCopyable&);
};

void f(const NotCopyable&);

void g() {
    f(NotCopyable());
}

$ ~/installed-packages/gcc-3.4.2/bin/g++ -c bug.cc 
bug.cc: In function `void g()':
bug.cc:5: Fehler: `NotCopyable::NotCopyable(const NotCopyable&)' is private
bug.cc:10: Fehler: within this context

I use to pass temporaries as const references quite often in my
code. What puzzles me is that a copy appears to be made.

Is that a bug in gcc or am I missing something?

Joerg


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