🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

bug report on g++-1.27.0

#1609
From: "Naoki Saito Ext. 5471", GEO-002
Date: Mon, 09 Jan 1989 14:24
141 lines
3301 bytes
	Dear FSF people;

I observed the bug of the g++ 1.27.0 as follows:

o When I compiled the following program, I got the fatal signal like this:

$ g++ -g -O -fchar-charconst -o vector vector.cc -lm -v
g++ version 1.27.0
 /usr/local/lib/gcc-cpp+ -v -undef -D__GNU__ -D__GNUG__ -Dmc68000 -Dsun -Dunix -D__OPTIMIZE__ vector.cc /tmp/cca23630.cpp
GNU CPP version 1.27.0
 /usr/local/lib/gcc-c++ /tmp/cca23630.cpp -quiet -dumpbase vector.cc -fchar-charconst -opt -version -G -o /tmp/cca23630.s
GNU C++ version 1.27.0 (68k, MIT syntax) compiled by GNU C version 1.27.
Failed assertion (0) at line 1569 of `search.c'.
g++: Program c++ got fatal signal 6.

o My machine is Sun 3/60 running Sun OS 3.4.  And tm.h -> tm-sun3+.h
and md -> ../gcc/m68k.md.

o The following is the input files.  The problem occurs when some member
functions of the class has accidentally the same name as the member variable
of its derived class.  Here, function at() is declared in class vector and int
at is also declared by in the derived class vec.  This kind of accident may
occur when classes gets bigger and should be warned by the complier.


Regards,
Naoki Saito (saito@sdr.slb.com)
Schlumberger-Doll Research

===============================================================================
// file vector.h

#include <stream.h>

class vector
{
  int* v;
  int sz;
  vector(int, int*);
public:
  vector(int);
  ~vector();
  int size();
  int& operator[](int);
  int& elem(int);
  vector at(int from = 0, int to = -1);
};

inline vector::vector(int n)
{
  if (n <= 0)
    exit(1);
  else
    {
      sz = n;
      v = new int[n];
    }
}
inline vector::vector(int n, int* buf)
{
  sz = n; v = buf;
}

inline vector::~vector()
{
  delete v;
}

inline int vector::size()
{
  return sz;
}

inline int& vector::operator[](int i)
{
  if (i < 0 || sz <= i)
    exit(1);
  else
    return v[i];
}

inline int& vector::elem(int i)
{
  return v[i];
}

class vec : public vector
{
  int low, high;
public:
  vec(int, int);
  int& elem(int);
  int& operator[](int);
  int at;
};

inline vec::vec(int m, int n) : (n - m + 1)
{
  if (n < m)
    {
      int tmp = m;  m = n; n = tmp;
    }
  low = m;
  high = n;
}

inline int& vec::operator[](int i)
{
  if (i < low || high < i)
    exit(1);
  else
    return elem(i);
}
			   
inline int& vec::elem(int i)
{
  return vector::elem(i-low);
}


===============================================================================
// file vector.cc: main program.

#include "vector.h"

main()
{
  vector a(10);
  for (int i = 0; i < a.size(); i++)
    {
      a[i] = i;
      cout << a[i] << " ";
    }
  cout << "\n";

  vec b(10, 19);
  for (i = 0; i < b.size(); i++) b[i+10] = a[i];
  for (i = 0; i < b.size(); i++) cout << b[i+10] << " ";
  cout << "\n";
}
Technical Details
Message-ID: <8901091624.AA03237@prep.ai.mit.edu>
Path: arc1-ca.pugleaf.net!utzoo!telly!ddsw1!lll-winken!killer!osu-cis!tut.cis.ohio-state.edu!sdr.slb.com!SAITO

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!ddsw1!lll-winken!killer!osu-cis!tut.cis.ohio-state.edu!sdr.slb.com!SAITO
From: SAITO@sdr.slb.com ("Naoki Saito  Ext. 5471", GEO-002)
Newsgroups: gnu.g++.bug
Subject: bug report on g++-1.27.0
Message-ID: <8901091624.AA03237@prep.ai.mit.edu>
Date: 9 Jan 89 14:24:00 GMT
Sender: news@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 141