🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by "Douglas C. Schmidt" Tue, 03 Jan 1989 01:14
protection error with g++ 1.32
#1592
Author: "Douglas C. Schmidt"
Date: Tue, 03 Jan 1989 01:14
41 lines
1432 bytes
Hi,

  The following short C++ program demonstrates a problem with g++
1.32's handling of private constructors in derived types:

----------------------------------------
class Base {
public:
   char *Protex;
   Base ( char *s ) {
      Protex = s;
   }
};

class Derived : public Base {
   Derived ( Base &b ) : ( b ) {
      printf ( "error: this is a private constructor!\n" );
   } 
};

int main ( int argc, char *argv [ ] ) {
   Base B ( argv [ 0 ] );
   Derived D ( B ); // this is an improper use of a private constructor
}
----------------------------------------

The variable definition and initialization for

  Derived D ( B );

makes an illicit call to a private constructor.  G++ 1.32 does not
complain about this.  AT&T cfront 1.2.1 correctly reports:

----------------------------------------
"bug.c", line 18: error:  Derived::Derived() is private 
----------------------------------------

more to come....!

Doug
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