🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Ron Guilmette Fri, 16 Jun 1989 19:04
failure to inline in G++ 1.35.0/sun3
#64
Author: Ron Guilmette
Date: Fri, 16 Jun 1989 19:04
76 lines
2526 bytes
As the following program demonstrates, g++ 1.35.0/sun3 handles inlining
of member functions (whose bodies are contained within their containing
class declaration) in a bass-akwards way.  Specifically, if a given
class declaration contains two member functions, and if one of these
member functions is "inline" and if the other member function contains
a call to the "inline" function, the call will *only* be inlined if
the "inline" function appears *** after *** the body of the calling
function!!!!!!!

			enilni

The reason for this "enilni" feature has to do with the order in which
g++ parses and compiles member functions.  Apparently, member functions
are "processed" by g++ in a "right-to-left" ordering, so that if you
want a member function inlined everywhere, you should put it *last*
in your class declaration, or better yet, place the body outside of
the class declaration altogether.

I have no idea how to fix this problem right now, but I hope that it
will be fixed so that "inlining" will take place "as expected", i.e.
in a top-to-bottom fashion, rather than in the current "bottom-to-top"
fashion.


// Ron Guilmette  -  MCC  -  Experimental Systems Kit Project
// 3500 West Balcones Center Drive,  Austin, TX  78759  -  (512)338-3740
// ARPA: rfg@mcc.com
// UUCP: {rutgers,uunet,gatech,ames,pyramid}!cs.utexas.edu!pp!rfg

----------------------------------------------------------------------
struct C {

	//  If you reverse the order of the following two declarations,
	//  you will get what you really wanted.

	inline void member_1 () { }
	inline void member_2 () { member_1 (); }
};

main ()
{
	C c;

	c.member_2 ();
}
------------------------------------------------------------------------
#NO_APP
gcc_compiled.:
.text
	.even
_member_1_PSC:
	link a6,#0
	movel a6@(8),d0
L4:
	unlk a6
	rts
	.even
.globl _main
_main:
	link a6,#-4
	moveml #0x3800,sp@-
	movel a6,d2
	subql #2,d2
	movel d2,d3
	movel a6,d0
	subql #2,d0
	movel d3,d4
	movel d4,sp@-
	jbsr _member_1_PSC		<=== inlining failed here
	addqw #4,sp
L6:
L5:
	moveml a6@(-16),#0x1c
	unlk a6
	rts
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads