public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/21631] New: Diagnostic for misdefined copy constructor is not particularly clear @ 2005-05-17 19:56 pkoning at equallogic dot com 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 ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: pkoning at equallogic dot com @ 2005-05-17 19:56 UTC (permalink / raw) To: gcc-bugs 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 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/21631] diagnostic for a non constant reference when passed a non lvalue (copy constructor) 2005-05-17 19:56 [Bug c++/21631] New: Diagnostic for misdefined copy constructor is not particularly clear pkoning at equallogic dot com @ 2005-05-17 20:00 ` 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 2 siblings, 0 replies; 4+ messages in thread From: pinskia at gcc dot gnu dot org @ 2005-05-17 20:00 UTC (permalink / raw) To: gcc-bugs ------- Additional Comments From pinskia at gcc dot gnu dot org 2005-05-17 20:00 ------- Confirmed, simple example: struct f { f(f&); }; int g(void) { f a = f(); } -- What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever Confirmed| |1 Keywords| |diagnostic Last reconfirmed|0000-00-00 00:00:00 |2005-05-17 20:00:40 date| | Summary|Diagnostic for misdefined |diagnostic for a non |copy constructor is not |constant reference when |particularly clear |passed a non lvalue (copy | |constructor) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21631 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/21631] diagnostic for a non constant reference when passed a non lvalue (copy constructor) 2005-05-17 19:56 [Bug c++/21631] New: Diagnostic for misdefined copy constructor is not particularly clear pkoning at equallogic dot com 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 2 siblings, 0 replies; 4+ messages in thread From: pinskia at gcc dot gnu dot org @ 2005-05-17 20:17 UTC (permalink / raw) To: gcc-bugs ------- Additional Comments From pinskia at gcc dot gnu dot org 2005-05-17 20:17 ------- Note T(T&) is still a copy constructor, just not one which takes a constant reference. Also note: it really bolls down to this testcase: int f(int&); int f(); int g(void) { return f(1); } If we get rid of the second f function, we get a good warning. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21631 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/21631] diagnostic for a non constant reference when passed a non lvalue (copy constructor) 2005-05-17 19:56 [Bug c++/21631] New: Diagnostic for misdefined copy constructor is not particularly clear pkoning at equallogic dot com 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 2 siblings, 0 replies; 4+ messages in thread From: pinskia at gcc dot gnu dot org @ 2005-09-17 3:58 UTC (permalink / raw) To: gcc-bugs -- What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |enhancement Last reconfirmed|2005-05-17 20:00:40 |2005-09-17 03:57:49 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21631 ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-09-17 3:58 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2005-05-17 19:56 [Bug c++/21631] New: Diagnostic for misdefined copy constructor is not particularly clear pkoning at equallogic dot com 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
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).