Problem with private copy constructor
Mathias Froehlich
M.Froehlich@science-computing.de
Mon Jun 26 09:57:00 GMT 2006
Hi,
I have a problem with that following code together with gcc-4.1.1.
#include <iostream>
class base {
public:
base()
{ std::cout << __PRETTY_FUNCTION__ << " " << this << std::endl; }
private:
base(const base&);
};
class derived : public base {
public:
derived()
{ std::cout << __PRETTY_FUNCTION__ << " " << this << std::endl; }
};
void fuu(const base& b)
{
}
int main()
{
fuu(derived());
return 17;
}
gcc bails out with the following error message:
gcctest2.cpp: In copy constructor 'derived::derived(const derived&)':
gcctest2.cpp:8: error: 'base::base(const base&)' is private
gcctest2.cpp:11: error: within this context
gcctest2.cpp: In function 'int main()':
gcctest2.cpp:23: note: synthesized method 'derived::derived(const derived&)'
first required here
>From my understanding of c++, I would not expect that this copy constructor is
called in this case. In fact, gcc-3.3.4 and various other UNIX c++ compilers
do not need that copy constructor either.
Do I need to dig out my copy of the C++ standard or is it something to file a
bugreport?
Greetings
Mathias
--
Dr. Mathias Fröhlich, science + computing ag, Software Solutions
Hagellocher Weg 71-75, D-72070 Tuebingen, Germany
Phone: +49 7071 9457-268, Fax: +49 7071 9457-511
More information about the Gcc-help
mailing list