🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by hps Thu, 26 Oct 1989 18:30
implicit conversion problem: 1.36
#551
Author: hps
Date: Thu, 26 Oct 1989 18:30
52 lines
1821 bytes
The following code fragment compiles under CC
----
#include <stream.h>
class D {
 public:
   D() {cout << "D() constructor\n";}
  ~D() {cout << "D destructor\n";}
};

class C {
 public:
   C(D&) {cout << "C(D&) constructor\n";}
   C() {cout << "C() constructor\n";}
  ~C() {cout << "C destructor\n";}
  friend C& operator=(C&,C&);
 };

C& operator=(C& cc, C& bb) {
 cout<<"operator=\n";
 return cc;
}

main() {
 D d;
 C c;
 c = d = c;
}
----
(produces a warning: line 19: warning: bb not used

under g++ it produces an error: 24:conversion between incompatible aggregate types
requested.

this is using version 1.36.0-

uhen substituting the equivalent expression
 operator=(c,operator=(d,c))

Produces the following output:
/usr/local/gnu/1.36/bin/g++ -v p1.cc
gcc version 1.36.0- (based on GCC 1.36)
 /usr/local/gnu/1.36/lib/gcc-cpp -+ -v -I/usr/local/gnu/1.36/lib/g++-include -undef -D__GNUC__ -D__GNUG__ -D__cplusplus -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ p1.cc /usr/tmp/cca02554.cpp
GNU CPP version 1.36
 /usr/local/gnu/1.36/lib/gcc-cc1plus /usr/tmp/cca02554.cpp -quiet -dumpbase p1.cc -version -o /usr/tmp/cca02554.s
GNU C++ version 1.36.0- (based on GCC 1.36) (sparc) compiled by GNU C version 1.36.
default target switches: -mfpu -mepilogue
p1.cc: In function int main ():
p1.cc:24: Segmentation violation
/usr/local/gnu/1.36/bin/real-g++: Program cc1plus got fatal signal 11.

-Page
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads