home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / gnu / g / bug / 2090 < prev    next >
Encoding:
Text File  |  1992-12-30  |  2.7 KB  |  77 lines

  1. Newsgroups: gnu.g++.bug
  2. Path: sparky!uunet!cis.ohio-state.edu!dfv.rwth-aachen.DE!mj
  3. From: mj@dfv.rwth-aachen.DE (Martin Junius)
  4. Subject: g++ 2.3.3: copy constructor bug still there
  5. Message-ID: <1992Dec29.160740.18789@dfv.rwth-aachen.de>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: Communication Networks
  8. Distribution: gnu
  9. Date: Tue, 29 Dec 1992 16:07:40 GMT
  10. Approved: bug-g++@prep.ai.mit.edu
  11. Lines: 64
  12.  
  13. This bug is still present in g++ 2.3.3:
  14.  
  15. ----bug-copy.C----------------------------------------------------------------
  16. #include <iostream.h>
  17.  
  18. class X;
  19.  
  20. class Y
  21. {
  22. public:
  23.     Y()           { /* cout << "Y::Y()\n"; */   }
  24.     Y(const X &x) { cout << "Y::Y(const X&)\n"; }
  25.     Y(const Y &y) { cout << "Y::Y(const Y&)\n"; }
  26. };
  27.  
  28. class X: public Y
  29. {
  30. public:
  31.     X()          { /*cout << "X::X()\n";*/         }
  32. // Uncommenting the following line will enforce the correct behaviour
  33. //  X(const X&x) { cout << "X::X(const X&)\n"; }
  34.     X(const Y&y) { cout << "X::X(const Y&)\n"; }
  35.     X getit() { cout << "X::getit()\n"; X x; return x; }
  36. };
  37.  
  38. main()
  39. {
  40.     X a, b;
  41.     
  42.     a = b.getit();
  43. }
  44. ----Compile--------------------------------------------------------------------------
  45. Reading specs from /usr/global/lib/gcc-lib/sparc/2.3.3/specs
  46. gcc version 2.3.3
  47.  /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
  48. GNU CPP version 2.3.3 (sparc)
  49.  /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
  50. GNU C++ version 2.3.3 (sparc) compiled by GNU C version 2.3.3.
  51.  as -o /usr/tmp/cca242411.o /usr/tmp/cca24241.s
  52.  /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
  53. ----Run-----------------------------------------------------------------------
  54. X::getit()
  55. X::X(const Y&)      <-- This is wrong!!!
  56. Y::Y(const Y&)
  57. ----Output should be (cfront 2.1)---------------------------------------------
  58. X::getit()
  59. Y::Y(const Y&)
  60. ------------------------------------------------------------------------------
  61.  
  62. g++ 2.3.3 doesn't generate a default copy constructor, but makes 
  63. strange detours if a constructor with an argument for which an 
  64. implicit type conversion exists is declared. This can be as worse 
  65. as casting the class thru an int!
  66.  
  67. This still is one of the major problems of compiling NIHCL 3.x 
  68. with GNU C++.
  69.  
  70. Martin
  71. -- 
  72.  _____ _____
  73. |     |___  |   Martin Junius           FIDO:      2:242/6.1
  74. | | | |   | |   Communication Networks  Internet:  mj@dfv.rwth-aachen.de
  75. |_|_|_|@work|   Aachen U of Technology  Phone:     ++49-241-8790220 (voice)
  76.  
  77.