[Bug c++/18113] New: compiler allows 2 copy constructors
The bug is simple : lets say : " class TObject; typedef TObject& rObject; class TObject { public: TObject(){} TObject(const TObject&); TObject(const rObject); }; TObject::TObject(const TObject&) { char*s; s="constructor 1"; } TObject::TObject(const rObject) { char*s; s="constructor 2"; } " In da function: " TObject F() { TObject AnObject; TObject anotherObject=AnObject;//constructor 2 !!! return AnObject; } " constructor 2 will be called! -- Summary: compiler allows 2 copy constructors Product: gcc Version: 3.3.2 Status: UNCONFIRMED Severity: critical Priority: P1 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: profvonsully at yahoo dot com CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: i386 GCC host triplet: i386 GCC target triplet: i386 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18113
[Bug c++/18113] compiler allows 2 copy constructors
--- Additional Comments From profvonsully at yahoo dot com 2004-10-22 16:53 --- Created an attachment (id=7402) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=7402&action=view) html file describing the bug no comment ;) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18113
[Bug c++/18113] compiler allows 2 copy constructors
--- Additional Comments From profvonsully at yahoo dot com 2004-10-26 18:41 --- there is another example for those that did not look at the attachment(sorry for my initial language): class TObject; typedef TObject& rObject; class TObject { public: TObject(){} TObject(const rObject){}//the compiler does NOT realize that this is a copy constructor //TObject(const TObject&){} the compiler wants this to be a copy constructor // "error: no matching function for call to `TObject::TObject(TObject)'" :))) //I am [EMAIL PROTECTED] }; TObject GetAnObject() { TObject AnObject; return AnObject; } void HandleObject(TObject toj) { } void errors_are_here() { HandleObject ( GetAnObject() );/*here g++ says an error exists*/ } -- What|Removed |Added Status|RESOLVED|UNCONFIRMED Resolution|INVALID | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18113
[Bug c++/18113] compiler allows 2 copy constructors
--- Additional Comments From profvonsully at yahoo dot com 2004-10-26 18:45 --- (In reply to comment #2) > look at the attahement ! -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18113
[Bug c++/18113] compiler allows 2 copy constructors
--- Additional Comments From profvonsully at yahoo dot com 2004-10-26 19:05 --- (In reply to comment #7 i dont care about the const . i descovered the bug in the first example of the attcahment where the compiler prints an error that is not logic(in borland C++ i used TObject(rObject) with no problem). If a fuction returns a TObject and I pass the result to a function that receives a TObject an error ocurs !! pls make me understand this :) -- What|Removed |Added Status|RESOLVED|UNCONFIRMED Resolution|INVALID | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18113
[Bug c++/18113] compiler allows 2 copy constructors
--- Additional Comments From profvonsully at yahoo dot com 2004-10-26 19:21 --- !!! in the second example only one constructor is writeed (to be compiled) "TObject(rTObject)"!!(the other one is in a coment and ... errror) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18113