[gnu.g++.bug] inline function bug?

fdpo@FALINE.BELLCORE.COM (Rick D. Porter) (12/07/89)

I am a neophyte C++ user, but I believe that the following program
should not core dump as it does:

I am running version 1.36.1 on a Sun4 running SunOS 4.0.3.

I ran g++ with the -g option only.

The config files were sparc.md and tm-sparc.h.


The following program illustrates the problem.  It core dumps in
Field::Field( RegInfo ).  The problem occurs when get_val(), an
inline member function, is called and its return value is not used.
The problem does NOT occur if the return value is used or if
get_val() is not inline.  It also does NOT occur if I compile it on
a Sun3 with SunOS 4.0.

Rick Porter
Bellcore
(201) 829-4490

------------------------------------------------------------

struct RegInfo {
	char val;
	char fake;
	
};

class Field {
	RegInfo* rip;
	char get_val();
    public:
	  Field(RegInfo& ) ;
	  Field() {};
	  ~Field() {};
};


inline char Field::get_val()
{
	return rip->fake;
}


Field::Field( RegInfo& ri )
{
	rip = &ri;
	
	get_val();		// Core dumps here
	ri.val = get_val();	// This executes OK
}	

main()
{
	RegInfo ri;

	Field f(  ri );
	
}