Re: Problem with private copy constructor

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This has changed sinced 3.4 and is now correct based on the standard:

http://gcc.gnu.org/bugs.html#cxx_rvalbind has good information on this.

corey

On 6/26/06, Mathias Froehlich <M.Froehlich@xxxxxxxxxxxxxxxxxxxx> wrote:

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



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux