home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / gnu / g / bug / 2112 < prev    next >
Encoding:
Text File  |  1993-01-02  |  1.9 KB  |  64 lines

  1. Newsgroups: gnu.g++.bug
  2. Path: sparky!uunet!spool.mu.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!thunder.mcrcim.mcgill.edu!peta
  3. From: peta@thunder.mcrcim.mcgill.edu (Peter Whaite)
  4. Subject: friend operator= declaration bug.
  5. Message-ID: <9301022047.AA27870@Thunder.McRCIM.McGill.EDU>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: GNUs Not Usenet
  8. Distribution: gnu
  9. Date: Sat, 2 Jan 1993 10:47:13 GMT
  10. Approved: bug-g++@prep.ai.mit.edu
  11. Lines: 51
  12.  
  13. Weird things happen when a friend operator= function is declared within a
  14. class.  See code comments below....
  15.  
  16. cd /home/tectum/peta/src/g++-bugs/
  17. make -k bug10-report
  18. uname -a
  19. SunOS Thunder.McRCIM.McGill.EDU 4.1.2 1 sun4
  20. cat bug10.cc
  21. // -*- C++ -*-
  22. //
  23. // The first declaration of a friend operator= function is used as the
  24. // default operator= declaration in any class that doesnt define its
  25. // own.
  26.  
  27. class FooA
  28. {
  29.     friend FooA& operator=(FooA&,FooA&);
  30. };
  31.  
  32. class FooB
  33. {
  34.     friend FooB& operator=(FooB&, FooB&);
  35. };
  36.  
  37. class Foo
  38. {
  39.   public:
  40.     // Declaring is enough to prevent the bug but it needs to be
  41.     // implemented for ld (of course)
  42. //    Foo& operator=(Foo&);
  43. };
  44.  
  45. main ()
  46. {
  47.     Foo f1,f2;
  48.     f1 = f2;
  49. }
  50. g++ -Wall -v -o bug10  bug10.cc
  51. Reading specs from /local/gnu/lib/gcc-lib/sun4/2.3.3/specs
  52. gcc version 2.3.3
  53.  /local/gnu/lib/gcc-lib/sun4/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 -Wall bug10.cc /usr/tmp/cca27698.i
  54. GNU CPP version 2.3.3 (sparc)
  55.  /local/gnu/lib/gcc-lib/sun4/2.3.3/cc1plus /usr/tmp/cca27698.i -quiet -dumpbase bug10.cc -Wall -version -o /usr/tmp/cca27698.s
  56. GNU C++ version 2.3.3 (sparc) compiled by GNU C version 2.3.3.
  57. bug10.cc: In function `int  main ()':
  58. bug10.cc:28: bad argument 0 for function `operator = (class FooA&, class FooA&)' (type was class Foo)
  59. make: *** [bug10-report] Error 1
  60.  
  61. Compilation exited abnormally with code 1 at Sat Jan  2 15:40:59
  62.  
  63.  
  64.