home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: gnu.g++.bug
- Path: sparky!uunet!spool.mu.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!thunder.mcrcim.mcgill.edu!peta
- From: peta@thunder.mcrcim.mcgill.edu (Peter Whaite)
- Subject: friend operator= declaration bug.
- Message-ID: <9301022047.AA27870@Thunder.McRCIM.McGill.EDU>
- Sender: gnulists@ai.mit.edu
- Organization: GNUs Not Usenet
- Distribution: gnu
- Date: Sat, 2 Jan 1993 10:47:13 GMT
- Approved: bug-g++@prep.ai.mit.edu
- Lines: 51
-
- Weird things happen when a friend operator= function is declared within a
- class. See code comments below....
-
- cd /home/tectum/peta/src/g++-bugs/
- make -k bug10-report
- uname -a
- SunOS Thunder.McRCIM.McGill.EDU 4.1.2 1 sun4
- cat bug10.cc
- // -*- C++ -*-
- //
- // The first declaration of a friend operator= function is used as the
- // default operator= declaration in any class that doesnt define its
- // own.
-
- class FooA
- {
- friend FooA& operator=(FooA&,FooA&);
- };
-
- class FooB
- {
- friend FooB& operator=(FooB&, FooB&);
- };
-
- class Foo
- {
- public:
- // Declaring is enough to prevent the bug but it needs to be
- // implemented for ld (of course)
- // Foo& operator=(Foo&);
- };
-
- main ()
- {
- Foo f1,f2;
- f1 = f2;
- }
- g++ -Wall -v -o bug10 bug10.cc
- Reading specs from /local/gnu/lib/gcc-lib/sun4/2.3.3/specs
- gcc version 2.3.3
- /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
- GNU CPP version 2.3.3 (sparc)
- /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
- GNU C++ version 2.3.3 (sparc) compiled by GNU C version 2.3.3.
- bug10.cc: In function `int main ()':
- bug10.cc:28: bad argument 0 for function `operator = (class FooA&, class FooA&)' (type was class Foo)
- make: *** [bug10-report] Error 1
-
- Compilation exited abnormally with code 1 at Sat Jan 2 15:40:59
-
-
-