public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "pkoning at equallogic dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/21631] New: Diagnostic for misdefined copy constructor is not particularly clear Date: Tue, 17 May 2005 19:56:00 -0000 [thread overview] Message-ID: <20050517195554.21631.pkoning@equallogic.com> (raw) If I define a copy constructor as T(T&) rather than the correct T(const T&), I'll end up with messages of the form: | > keyed_obj.hh:159: error: no matching function for call to 'CxnIndex::CxnIndex(CxnIndex)' | > Indeces.hh:150: note: candidates are: CxnIndex::CxnIndex(CxnIndex&) which is baffling to most users because usually an argument of type T& is acceptable for a call with a type T argument. It doesn't help that there isn't a call in the source code -- the compiler generated a copy constructor reference, for reasons that may not be obvious from reading the source. It would be helpful if the compiler could guide the user to the fix, perhaps by doing one or both of the following: a. Warn on the declaration of T(T&) with a message along the lines of "that looks like a copy constructor, but it really should be T(const T&)" b. In the message I quoted above, mention that a T(const T&) is needed and was not supplied. -- Summary: Diagnostic for misdefined copy constructor is not particularly clear Product: gcc Version: 4.0.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: pkoning at equallogic dot com CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: i386-netbsd GCC host triplet: i386-netbsd GCC target triplet: mipsel-netbsdelf http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21631
next reply other threads:[~2005-05-17 19:56 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2005-05-17 19:56 pkoning at equallogic dot com [this message] 2005-05-17 20:00 ` [Bug c++/21631] diagnostic for a non constant reference when passed a non lvalue (copy constructor) pinskia at gcc dot gnu dot org 2005-05-17 20:17 ` pinskia at gcc dot gnu dot org 2005-09-17 3:58 ` pinskia at gcc dot gnu dot org
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=20050517195554.21631.pkoning@equallogic.com \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@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: linkBe 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).