[gnu.g++.bug] bug in g++ 1.34.0

grunwald%flute.cs.uiuc.edu@A.CS.UIUC.EDU (Dirk Grunwald) (03/14/89)

configuration: stock g++ 1.34.0, compiled using gcc-1.34 on a Sun-3/60
problem: get following assertion
 Failed assertion visibility != visibility_protected at line 3298 of `cplus-class.c'.

GDB session & squeezed code follows

Current directory is /usr/local/Gnu/lib/
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 /usr/local/Gnu/lib/gcc-c++...done.
Type "help" for a list of commands.
(gdb) dir /mnt/tapestry/Tools/Src/G++/g++-1.34.0
Source directories searched: /usr/local/Gnu/lib:/mnt/tapestry/Tools/Src/G++/g++-1.34.0
(gdb) run -noreg -version -o /dev/null BUG.cc
Starting program: /usr/local/Gnu/lib/gcc-c++ -noreg -version -o /dev/null BUG.cc
GNU C++ version 1.34.0 (68k, MIT syntax) compiled by GNU C version 1.34.
c++: BUG.cc: No such file or directory

Program exited with code 043.
(gdb) pwd
Working directory /usr/local/Gnu/lib
 (canonically /share/guitar/Gnu/lib).
(gdb) cd /home/reed/grunwald/Workload/Sun
Working directory /home/reed/grunwald/Workload/Sun.
(gdb) run
Starting program: /usr/local/Gnu/lib/gcc-c++ -noreg -version -o /dev/null BUG.cc
GNU C++ version 1.34.0 (68k, MIT syntax) compiled by GNU C version 1.34.
abs (double); abs (long int); sign (long int); sign (double); sqr (long int); sqr (double); even (long int); odd (long int); lcm (long int, long int); setbit (long int &, long int); clearbit (long int &, long int); testbit (long int, long int); File::filedesc (); File::name (); File::iocount (); File::readable (); File::writable (); File::is_open (); File::clear (enum state_value (=  0 )); File::raw (); File::check_state (); File::failif (int); File::get (char &); File::put (char); File::unget (char); File

::putback (char); File::read (void *, int, int); File::write (void *, int, int); File::flush (); File::seek (long int, int (=  0 )); File::tell (); File::rdstate (); File::operator void *(); File::eof (); File::fail (); File::bad (); File::good (); ostream::operator void *(); ostream::operator << (char); ostream::operator << (const char *); istream::operator void *(); istream::_flush (); istream::operator >> (char &); 
At top level:
/usr/include/CC/signal.h:9: warning: lazy prototyping frowned upon
/usr/local/include/Awe2/HardwareContext.h:65: warning: class HardwareContext only defines private constructors
HardwareContext::mallocAt (); operator << (struct ostream &, const struct HardwareContext &); HardwareContext::maxStackDepth (); HardwareContext::checkStack (int); ExceptionClass::ExceptionClass (); ExceptionReserve::ExceptionReserve (); ExceptionReserve::reserve (); ExceptionReserve::reserve (struct ReserveByException *); ExceptionTerminate::ExceptionTerminate (); ExceptionTerminate::terminate (void **); ExceptionReschedule::ExceptionReschedule (); ExceptionReschedule::cpu (int); ExceptionIveSuspended::Ex

ceptionIveSuspended (); ExceptionEnrollDismissCpu::enroll (); ExceptionEnrollDismissCpu::dismiss (); SpinLock::SpinLock (); SpinLock::SpinLock (const int); SpinLock::reserve (); SpinLock::release (); SpinLock::count (); Awesime::Awesime (enum bool (=  0 )); Awesime::Awesime (const int); operator << (struct ostream &, const struct Awesime &); ThreadContainer::ThreadContainer (enum b

rfg@MCC.COM (Ron Guilmette) (03/15/89)

The following code produces what seems to be a bogus error message.
Are methods allowed to be static?

---------------------------------------------------------------------
// Check that a class method may be declared to be static

#include "testinc.h"

class c {
public:
	static void method1 ();
};

int test ()
{
	c c_object;

	c_object.method1 ();
	return 0;
}

static void c::method1 ()
{
}
----------------------------------------------------------------------
g++ -Wall -Wwrite-strings -v -S x04.C
g++ version 1.34.0.1
 /usr/local/src/lib/1.34.0.1/sun3/gcc-cpp -+ -v -undef -D__GNU__ -D__GNUG__ -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -Wall -D__HAVE_68881__ -Dmc68020 x04.C /tmp/cca20113.cpp
GNU CPP version 1.34.0.1
 /usr/local/src/lib/1.34.0.1/sun3/gcc-c++ /tmp/cca20113.cpp -quiet -dumpbase x04.C -Wall -Wwrite-strings -noreg -version -o x04.s
GNU C++ version 1.34.0.1 (68k, MIT syntax) compiled by GNU C version 1.33.
x04.C:7: sorry, not implemented: function declared static in class

rfg@MCC.COM (Ron Guilmette) (03/15/89)

This chunk of code also produces what appears to be a bogus error
message.  Are methods allowed to be extern?

----------------------------------------------------------------------------
// Check that a class method may be declared to be extern

#include "testinc.h"

class c {
public:
	extern void method1 ();
};

int test ()
{
	c c_object;

	c_object.method1 ();
	return 0;
}

extern void c::method1 ()
{
}
------------------------------------------------------------------------------
g++ -Wall -Wwrite-strings -v -S x05.C
g++ version 1.34.0.1
 /usr/local/src/lib/1.34.0.1/sun3/gcc-cpp -+ -v -undef -D__GNU__ -D__GNUG__ -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -Wall -D__HAVE_68881__ -Dmc68020 x05.C /tmp/cca20136.cpp
GNU CPP version 1.34.0.1
 /usr/local/src/lib/1.34.0.1/sun3/gcc-c++ /tmp/cca20136.cpp -quiet -dumpbase x05.C -Wall -Wwrite-strings -noreg -version -o x05.s
GNU C++ version 1.34.0.1 (68k, MIT syntax) compiled by GNU C version 1.33.
x05.C:7: storage class specified for structure field `method1'

steveng@GARP.MIT.EDU (Stephen Ng) (07/20/89)

I'd like to report a bug in g++ 1.34.0.  The following test case 
produces bad code--a function that should return true returns false
instead.  I've included a shell script which compiles the code and
runs it through different cases, and a log of the output.  

We are using tm-sun3.h, and m68k.md.

The compiler flags are given in the shell script.

I am running this on a Next machine, running Mach.  We are using 
release 0.9 of the Next software.


Thanks,

Stephen Ng

---------------------Cut Here--------------------------------------
: shar archive
: run this file through /bin/sh to extract its contents
if test -r "test.cc"
then
	echo "Will not overwrite existing copy of test.cc"
else
	echo "Extracting test.cc"
	sed 's/^X//' > test.cc <<\!!!END-OF-FILE!!!
X/********* PARAMETERS TO TURN THE BUG ON OR OFF *************/
X/*********** DEFAULT VALUES CAUSE BUG TO OCCUR **************/
X
X#if !defined(DATUM_TYPE)		// data type of model & table numbers
X#define DATUM_TYPE char
X#endif
X
X#if !defined(INLINE)
X#define INLINE inline
X#endif
X
X#define BEFORE 0
X#define AFTER 1
X#define NO_LOCAL 2
X
X#if !defined(LOCAL_VAR_POSITION)
X#define LOCAL_VAR_POSITION AFTER
X#endif
X
X/************************************************************/
X
Xtypedef unsigned DATUM_TYPE MDLNO;
Xtypedef unsigned DATUM_TYPE TBLNO;
X
Xclass TH {
X
X	MDLNO ModelNumber;						// External model # (0 is self)
X	TBLNO TableNumber;						// Table # within designated model
X
Xpublic:
X
X	//	N.B.	Definitions are deferred until after the class declaration to
X	//			get around a G++ bug with declaring constructors/destructors
X	//			to be "inline".
X
X	TH(MDLNO mdlno, TBLNO tblno);
X
X	INLINE MDLNO& theModel()			// Get/Set model
X		{return(ModelNumber);}
X
X	INLINE TBLNO& theTable()			// Get/Set Table
X		{return(TableNumber);}
X
X	INLINE int equal(TH cmp) {
X		return (ModelNumber==cmp.theModel()) &&
X				(TableNumber==cmp.theTable());
X		}
X};
X//	Deferred definitions of constructors and destructors.
Xstatic INLINE TH::TH(MDLNO mdlno, TBLNO tblno)
X	{ModelNumber = mdlno; TableNumber = tblno;}
X
Xclass test_class
X{
Xpublic:
X  TH test_class_th;
X
X  test_class(MDLNO m, TBLNO t);
X
X  void test_me(MDLNO m, TBLNO t);
X};
X
Xtest_class::test_class(MDLNO m, TBLNO t) :
X  test_class_th(m, t)
X{
X}
X
Xvoid test_class::test_me(MDLNO m, TBLNO t)
X	{
X#if LOCAL_VAR_POSITION == BEFORE
X	  char local_char;
X#endif
X
X	  TH			localTH(m, t);
X
X#if LOCAL_VAR_POSITION == AFTER
X	  char local_char;
X#endif
X	  if (test_class_th.equal(localTH) )
X		printf("generated good code\n");
X	  else
X		printf("generated bad code\n");
X	}
X
Xmain()
X{
X
X  test_class f(1, 2);
X
X  f.test_me(1, 2);
X}
!!!END-OF-FILE!!!
fi
if test -r "do_test"
then
	echo "Will not overwrite existing copy of do_test"
else
	echo "Extracting do_test"
	sed 's/^X//' > do_test <<\!!!END-OF-FILE!!!
X#!/bin/sh
X#
X#Generate run all variations of test program to see which generate bugs
X
Xgentest(){
X# $1 is DATUM_TYPE
X# $2 is VAR_POSITION
X# $3 is INLINE=
X
Xif [ -z "$3" ]
Xthen OFILE=test.$1.$2.no_inline
Xelse OFILE=test.$1.$2.inline
Xfi
X
Xecho compiling g++ -DDATUM_TYPE=$1 -DLOCAL_VAR_POSITION=$2 -DINLINE=$3 -o $OFILE test.cc
Xg++ -DDATUM_TYPE=$1 -DLOCAL_VAR_POSITION=$2 -DINLINE=$3 -o $OFILE -L/exec/lib test.cc
Xecho Running $OFILE
X$OFILE
X}
X
X# MAIN
X
Xgentest char BEFORE  inline
Xgentest char AFTER  inline
Xgentest char NO_LOCAL  inline
Xgentest short BEFORE  inline
Xgentest short AFTER  inline
Xgentest short NO_LOCAL  inline
Xgentest char BEFORE  
Xgentest char AFTER  
Xgentest char NO_LOCAL  
Xgentest short BEFORE  
Xgentest short AFTER  
Xgentest short NO_LOCAL  
X
X
X
!!!END-OF-FILE!!!
fi
if test -r "do_test.log"
then
	echo "Will not overwrite existing copy of do_test.log"
else
	echo "Extracting do_test.log"
	sed 's/^X//' > do_test.log <<\!!!END-OF-FILE!!!
Xcompiling g++ -DDATUM_TYPE=char -DLOCAL_VAR_POSITION=BEFORE -DINLINE=inline -o test.char.BEFORE.inline test.cc
XRunning test.char.BEFORE.inline
Xgenerated good code
Xcompiling g++ -DDATUM_TYPE=char -DLOCAL_VAR_POSITION=AFTER -DINLINE=inline -o test.char.AFTER.inline test.cc
XRunning test.char.AFTER.inline
Xgenerated bad code
Xcompiling g++ -DDATUM_TYPE=char -DLOCAL_VAR_POSITION=NO_LOCAL -DINLINE=inline -o test.char.NO_LOCAL.inline test.cc
XRunning test.char.NO_LOCAL.inline
Xgenerated good code
Xcompiling g++ -DDATUM_TYPE=short -DLOCAL_VAR_POSITION=BEFORE -DINLINE=inline -o test.short.BEFORE.inline test.cc
XRunning test.short.BEFORE.inline
Xgenerated good code
Xcompiling g++ -DDATUM_TYPE=short -DLOCAL_VAR_POSITION=AFTER -DINLINE=inline -o test.short.AFTER.inline test.cc
XRunning test.short.AFTER.inline
Xgenerated good code
Xcompiling g++ -DDATUM_TYPE=short -DLOCAL_VAR_POSITION=NO_LOCAL -DINLINE=inline -o test.short.NO_LOCAL.inline test.cc
XRunning test.short.NO_LOCAL.inline
Xgenerated good code
Xcompiling g++ -DDATUM_TYPE=char -DLOCAL_VAR_POSITION=BEFORE -DINLINE= -o test.char.BEFORE.no_inline test.cc
XRunning test.char.BEFORE.no_inline
Xgenerated good code
Xcompiling g++ -DDATUM_TYPE=char -DLOCAL_VAR_POSITION=AFTER -DINLINE= -o test.char.AFTER.no_inline test.cc
XRunning test.char.AFTER.no_inline
Xgenerated good code
Xcompiling g++ -DDATUM_TYPE=char -DLOCAL_VAR_POSITION=NO_LOCAL -DINLINE= -o test.char.NO_LOCAL.no_inline test.cc
XRunning test.char.NO_LOCAL.no_inline
Xgenerated good code
Xcompiling g++ -DDATUM_TYPE=short -DLOCAL_VAR_POSITION=BEFORE -DINLINE= -o test.short.BEFORE.no_inline test.cc
XRunning test.short.BEFORE.no_inline
Xgenerated good code
Xcompiling g++ -DDATUM_TYPE=short -DLOCAL_VAR_POSITION=AFTER -DINLINE= -o test.short.AFTER.no_inline test.cc
XRunning test.short.AFTER.no_inline
Xgenerated good code
Xcompiling g++ -DDATUM_TYPE=short -DLOCAL_VAR_POSITION=NO_LOCAL -DINLINE= -o test.short.NO_LOCAL.no_inline test.cc
XRunning test.short.NO_LOCAL.no_inline
Xgenerated good code
!!!END-OF-FILE!!!
fi