🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

3 Bugs

#2040
From: Per Mildner
Date: Thu, 25 May 1989 03:15
78 lines
1924 bytes
I'm Per-Mildner@AIDA.CSD.UU.SE

 Configuration:
SUN 4 with OS 4
tm.h -> config/tm-sparc+.h
md -> config/sparc.md
g++ version 1.35.0
g++ -Wall -O program.cc

1.
I don't know if this is a bug, but:
It would be useful if structures could have size zero.
This could eg be used ot inherit a bunch of static members.

#include <stream.h>

class foo {
  static int x;
};

int main(int argc, char* argv[]) {
  cout << "sizeof(foo)==" << sizeof(foo) << ".\n"; // says 1 on my system
  return 0;

};

2.
class C {
public:
  int slot;
  friend int bug(C c) {return c.slot;}
};
  
/*
g++ -Wall -c friend-inline-bug.cc
friend-inline-bug.cc:4: warning: `int bug (struct C)' declared but never defined
I get this even if I actually use the function (it gets defined and
works ok).
*/

3.
#include <stream.h>

class base {
 public:
  long field;
  virtual int f () {return 1*field;};
};

class derived : public base {
 public:
  int f () {return 2*field;}
};

struct foo {
  base aa,bb;
};

void bug (base& a, base& b) {
  cout << "a: " << a.f() << ", b: " << b.f() << ".\n";
  struct foo aabb;
  aabb.aa = a;
  aabb.bb = b;
  // This gives a segmentation fault.
  // Similar circumstances did print but used base::f() for both structure components.
  // (which might be the correct behaviour)
  cout << "aabb.aa.f(): " << aabb.aa.f() << ", aabb.bb.f(): " << aabb.bb.f() << ".\n";
};

int main(int argc, char* argv[]) {
  base b;
  derived d;
  b.field=2;
  d.field=11;
  bug(b,d);
  return 0;
};
Technical Details
Message-ID: <8905250315.AA27270@mizar.DoCS.UU.SE>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!mizar.docs.uu.se!perm

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!mizar.docs.uu.se!perm
From: perm@mizar.docs.uu.se (Per Mildner)
Newsgroups: gnu.g++.bug
Subject: 3 Bugs
Message-ID: <8905250315.AA27270@mizar.DoCS.UU.SE>
Date: 25 May 89 03:15:08 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 78