🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

virtual base classes

#1988
From: James Clark
Date: Thu, 11 May 1989 18:06
66 lines
2228 bytes
I'm having problems with virtual base classes:

Script started on Thu May 11 18:53:46 1989
jclark% cat test.c
#include <stdio.h>

struct A {
  int n;
  void set(int);
  void print();
};

void A::set(int i)
{
  n = i;
}

void A::print()
{
  fprintf(stderr, "%d\n", n);
}

struct B : virtual A {
};


main()
{
  B *p = new B;
  p->set(5);
  p->print();
  fprintf(stderr, "p->n = %d\n", p->n);
}
jclark% make test
/u/local/g++/g++ -B/u/local/g++/ -g -v -I.   -sun4 -o test test.c 
g++ version 1.35.0-
 /usr/local/lib/gcc-cpp -+ -v -I. -undef -D__GNU__ -D__GNUG__ -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ test.c /tmp/cca25650.cpp
GNU CPP version 1.35
 /u/local/g++/cc1plus /tmp/cca25650.cpp -quiet -dumpbase test.c -noreg -version -G -o /tmp/cca25650.s
GNU C++ version 1.35.0- (sparc) compiled by GNU C version 1.35.
 as /tmp/cca25650.s -o test.o
 /u/local/g++/ld++ -o test -C -C /u/local/g++/crt0+.o test.o -lg++ /usr/local/lib/gcc-gnulib -lg -lc
/u/local/g++/g++: unrecognized option `-sun4'
jclark% test
Segmentation fault (core dumped)
jclark% gdb test core
GDB 3.1, Copyright (C) 1988 Free Software Foundation, Inc.
There is ABSOLUTELY NO WARRANTY for GDB; type "info warranty" for details.
GDB is free software and you are welcome to distribute copies of it
 under certain conditions; type "info copying" to see the conditions.
Reading symbol data from /u/jjc/test/test...done.
Core file is from "test".
Program terminated with signal 11, Segmentation fault.
Type "help" for a list of commands.
(gdb) where
#0  0x2120 in set_PSA_SI ($this=(struct A *) 0x0, i=5) (test.c line 11)
#1  0x2198 in main () (test.c line 26)
(gdb) quit
jclark% exit
jclark% 
script done on Thu May 11 18:54:21 1989

If I've understood virtual base classes, this ought to have worked.

James Clark
jjc@jclark.uucp
Technical Details
Message-ID: <8905111806.AA25693@jclark.uucp>
Path: arc1-ca.pugleaf.net!utzoo!telly!attcan!uunet!tut.cis.ohio-state.edu!UUNET.UU.NET!jclark!jjc

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!attcan!uunet!tut.cis.ohio-state.edu!UUNET.UU.NET!jclark!jjc
From: jclark!jjc@UUNET.UU.NET (James Clark)
Newsgroups: gnu.g++.bug
Subject: virtual base classes
Message-ID: <8905111806.AA25693@jclark.uucp>
Date: 11 May 89 18:06:23 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 66