🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

inline function bug?

#684
From: Rick D. Porter
Date: Wed, 06 Dec 1989 16:52
60 lines
1544 bytes
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 );
	
}
Technical Details
Message-ID: <8912061652.AA16202@faline.bellcore.com>
Path: arc1-ca.pugleaf.net!utzoo!telly!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!FALINE.BELLCORE.COM!fdpo

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!FALINE.BELLCORE.COM!fdpo
From: fdpo@FALINE.BELLCORE.COM (Rick D. Porter)
Newsgroups: gnu.g++.bug
Subject: inline function bug?
Message-ID: <8912061652.AA16202@faline.bellcore.com>
Date: 6 Dec 89 16:52:58 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 60