From: Mathias Froehlich <M.Froehlich@science-computing.de>
To: gcc-help@gcc.gnu.org
Subject: Problem with private copy constructor
Date: Mon, 26 Jun 2006 09:57:00 -0000 [thread overview]
Message-ID: <200606261157.42075.M.Froehlich@science-computing.de> (raw)
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
next reply other threads:[~2006-06-26 9:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-26 9:57 Mathias Froehlich [this message]
2006-06-26 10:11 ` corey taylor
2006-06-26 11:15 ` Mathias Froehlich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200606261157.42075.M.Froehlich@science-computing.de \
--to=m.froehlich@science-computing.de \
--cc=gcc-help@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).