home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: gnu.g++.bug
- Path: sparky!uunet!cis.ohio-state.edu!dfv.rwth-aachen.DE!mj
- From: mj@dfv.rwth-aachen.DE (Martin Junius)
- Subject: g++ 2.3.3: copy constructor bug still there
- Message-ID: <1992Dec29.160740.18789@dfv.rwth-aachen.de>
- Sender: gnulists@ai.mit.edu
- Organization: Communication Networks
- Distribution: gnu
- Date: Tue, 29 Dec 1992 16:07:40 GMT
- Approved: bug-g++@prep.ai.mit.edu
- Lines: 64
-
- This bug is still present in g++ 2.3.3:
-
- ----bug-copy.C----------------------------------------------------------------
- #include <iostream.h>
-
- class X;
-
- class Y
- {
- public:
- Y() { /* cout << "Y::Y()\n"; */ }
- Y(const X &x) { cout << "Y::Y(const X&)\n"; }
- Y(const Y &y) { cout << "Y::Y(const Y&)\n"; }
- };
-
- class X: public Y
- {
- public:
- X() { /*cout << "X::X()\n";*/ }
- // Uncommenting the following line will enforce the correct behaviour
- // X(const X&x) { cout << "X::X(const X&)\n"; }
- X(const Y&y) { cout << "X::X(const Y&)\n"; }
- X getit() { cout << "X::getit()\n"; X x; return x; }
- };
-
- main()
- {
- X a, b;
-
- a = b.getit();
- }
- ----Compile--------------------------------------------------------------------------
- Reading specs from /usr/global/lib/gcc-lib/sparc/2.3.3/specs
- gcc version 2.3.3
- /usr/global/lib/gcc-lib/sparc/2.3.3/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ -D__sparc -D__sun -D__unix bug-copy.C /usr/tmp/cca24241.i
- GNU CPP version 2.3.3 (sparc)
- /usr/global/lib/gcc-lib/sparc/2.3.3/cc1plus /usr/tmp/cca24241.i -quiet -dumpbase bug-copy.cc -version -o /usr/tmp/cca24241.s
- GNU C++ version 2.3.3 (sparc) compiled by GNU C version 2.3.3.
- as -o /usr/tmp/cca242411.o /usr/tmp/cca24241.s
- /usr/global/lib/gcc-lib/sparc/2.3.3/ld -e start -dc -dp /lib/crt0.o -L/usr/global/lib/gcc-lib/sparc/2.3.3 -L/usr/global/lib /usr/tmp/cca242411.o -lg++ -lgcc -lc -lgcc
- ----Run-----------------------------------------------------------------------
- X::getit()
- X::X(const Y&) <-- This is wrong!!!
- Y::Y(const Y&)
- ----Output should be (cfront 2.1)---------------------------------------------
- X::getit()
- Y::Y(const Y&)
- ------------------------------------------------------------------------------
-
- g++ 2.3.3 doesn't generate a default copy constructor, but makes
- strange detours if a constructor with an argument for which an
- implicit type conversion exists is declared. This can be as worse
- as casting the class thru an int!
-
- This still is one of the major problems of compiling NIHCL 3.x
- with GNU C++.
-
- Martin
- --
- _____ _____
- | |___ | Martin Junius FIDO: 2:242/6.1
- | | | | | | Communication Networks Internet: mj@dfv.rwth-aachen.de
- |_|_|_|@work| Aachen U of Technology Phone: ++49-241-8790220 (voice)
-
-