[gnu.g++.bug] g++ 1.35.0, sun3-os4; signal 11 while compiling

hinman@IMPOSTER.SAMSUNG.COM (David Hinman) (07/28/89)

When I compile the following test program, I get a segmentation violation.
When the structure declaration is removed from the class, the problem goes away.

>>> The code:
/*  g++ 1.35.0, sun3-os4; signal 11 while compiling */
class ObjectTable 
	{
	
private:

	typedef struct ote_struct
		{
		int x;
		int y;
		} ObjectTableElement;

	ObjectTableElement ote;

	ObjectTableElement* index() { return &ote; }

public:
	void     setNBytes();
	};

>>> The compiler messages:
imposter hinman> g++ -v -g -c test23.C
g++ version 1.35.0
 /usr/local/pkg/gnu/compilers/sun3new/gcc-cpp -+ -v -undef -D__GNU__ -D__GNUG__
-D__cplusplus -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -D__HAVE
_68881__ -Dmc68020 test23.C /tmp/cca18439.cpp
GNU CPP version 1.35
 /usr/local/pkg/gnu/compilers/sun3new/gcc-cc1plus /tmp/cca18439.cpp -quiet -dump
base test23.C -noreg -version -G -o /tmp/cca18439.s
GNU C++ version 1.35.0 (68k, MIT syntax) compiled by GNU C version 1.35.
In method struct ote_struct *ObjectTable::index ():
test23.C:14: Segmentation violation
g++: Program cc1plus got fatal signal 11.
imposter hinman>

>>> The pat on the back:
I'm a happy user of FSF products; thanks for sharing your software!

Dave Hinman                         
Samsung Software America           (508) 685-7200 ext. 124
One Corporate Drive                hinman@ginosko.samsung.com
Andover, MA 01810                  uunet!ginosko!hinman

tiemann@YAHI.STANFORD.EDU (Michael Tiemann) (07/28/89)

    When I compile the following test program, I get a segmentation violation.
    When the structure declaration is removed from the class, the problem goes away.

    >>> The code:
    /*  g++ 1.35.0, sun3-os4; signal 11 while compiling */
    class ObjectTable 
	    {

    private:

	    typedef struct ote_struct
		    {
		    int x;
		    int y;
		    } ObjectTableElement;

	    ObjectTableElement ote;

	    ObjectTableElement* index() { return &ote; }

    public:
	    void     setNBytes();
	    };

Fix: in cplus-search.c (dfs_pushdecls):

  for (fields = TYPE_FIELDS (type); fields; fields = TREE_CHAIN (fields))
    {
      /* Unmark so that if we are in a constructor, and then find that
	 this field was initialized by a base initializer,
	 we can emit an error message.  */
      TREE_USED (fields) = 0;
      if (DECL_ANON_UNION_ELEM (fields))
	{
	  dfs_pushdecls (TREE_TYPE (fields));
	  continue;
	}
+      if (TREE_CODE (fields) == TYPE_DECL)
+	continue;

Michael