Article View: gnu.g++.bug
Article #64failure to inline in G++ 1.35.0/sun3
From: Ron Guilmette
Date: Fri, 16 Jun 1989 19:04
Date: Fri, 16 Jun 1989 19:04
76 lines
2526 bytes
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
Technical Details
Message-ID:
<8906161904.AA03145@pink.aca.mcc.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!MCC.COM!rfgShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!MCC.COM!rfg From: rfg@MCC.COM (Ron Guilmette) Newsgroups: gnu.g++.bug Subject: failure to inline in G++ 1.35.0/sun3 Message-ID: <8906161904.AA03145@pink.aca.mcc.com> Date: 16 Jun 89 19:04:58 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 76