🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #1777

(fatal) bug in c++

#1777
From: Carl Staelin
Date: Wed, 22 Mar 1989 21:44
103 lines
2810 bytes
In order to facilitate debugging of my code, I have a conversion routine
"operator String" associated with each object, which creates a human readable
string of the current state of the object.  Since I use inheritance,
I would like to be able to access a parent's conversion routine, and include
the result in the child.  There doesn't seem to be a way to do this, and the
only reasonable method using scoping causes the c++ program to fail.

A sample program is included below.

On another subject, I am using g++ under MACH, and I would like to be able to
use gdb to debug my programs.  Unfortunately version 3.1 doesn't work under
MACH, and the version of gdb which has been modified to work with MACH by 
CMU is version 2.4, which doesn't work with g++.  Do you know of anyone who
has modified gdb 3.1 to work under MACH?

Thanks,
	Carl Staelin

**************** program which kills c++ ***********************************
// this may look like C code, but it is really -*- C++ -*-


#include <std.h>
#include <stdio.h>
#include <stream.h>
#include <assert.h>
#include <String.h>
#include <Pix.h>


/*
  various typedefs to save typing
  */
typedef long unsigned int l_u_int;
typedef l_u_int* l_u_int_p;

typedef long int l_int;
typedef l_int* l_int_p;

typedef unsigned int u_int;
typedef u_int* u_int_p;

typedef unsigned short u_short;
typedef u_short* u_short_p;

typedef unsigned char u_char;
typedef u_char* u_char_p;

typedef int*   int_p;
typedef short* short_p;
typedef char*  char_p;
typedef void*  void_p;

typedef char   Boolean;

class Root_class
{
 private:
 public:
  
  Root_class();
  ~Root_class();

  int debug;
  String operator String();
};

typedef Root_class* Root_class_p;

class Child_class : public Root_class
{
 private:
 public:
  Child_class();
  ~Child_class();

  String operator String();
};

typedef Child_class* Child_class_p;

Root_class::Root_class() { debug = 0; }

Root_class::~Root_class() {}

String Root_class::operator String()
{
  String result = form ("Root_class <0x%x> = { %d }", (l_u_int)this, debug);

  return result;
}

Child_class::Child_class() {}

Child_class::~Child_class() {}

String Child_class::operator String()
{
  String result = form ("Child_class <0x%x> = { %s }", 
			(char *)Root_class::operator String());

  return result;
}
Technical Details
Message-ID: <8903222144.AA07733@thrash.princeton.edu>
Path: arc1-ca.pugleaf.net!utzoo!telly!attcan!dptcdc!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!THRASH.PRINCETON.EDU!staelin

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!attcan!dptcdc!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!THRASH.PRINCETON.EDU!staelin
From: staelin@THRASH.PRINCETON.EDU (Carl Staelin)
Newsgroups: gnu.g++.bug
Subject: (fatal) bug in c++
Message-ID: <8903222144.AA07733@thrash.princeton.edu>
Date: 22 Mar 89 21:44:17 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 103