This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
(3.4.2 Bug?) Copy ctor needed to pass temporary as const reference?
- From: Faschingbauer <jfasch at salomon dot at>
- To: gcc at gcc dot gnu dot org
- Date: Sat, 11 Sep 2004 09:50:58 +0200 (CEST)
- Subject: (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