🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

g++ internal compiler error

#1317
From: jimc
Date: Mon, 04 Jan 1993 07:57
70 lines
2503 bytes
Gnu g++ v2.3.2 for Sparc-Sun-SunOS 4.1.1

Friend function A is defined inside the class.  Member function B is
also  defined inside the class definition and uses function A.  When B
is used the invocation of A is not expanded inline; neither is a body
generated for A.  I believe it fails equally if A is a member function,
and if A is a user-named function (not overloaded operator).
 

James F. Carter        (213) 825-2897
UCLA-Mathnet;  6221 MSA; 405 Hilgard Ave.; Los Angeles, CA, USA  90024-1555
Internet: jimc@math.ucla.edu            BITNET: jimc%math.ucla.edu@INTERBIT
UUCP:...!{ucsd,ames,ncar,gatech,purdue,rutgers,decvax,uunet}!math.ucla.edu!jimc

---------- Linker output

ld: Undefined symbol 
   ___ls__FR7ostreamRC5zilch 
collect: /usr/bin/ld returned 2 exit status

---------- Source code: main program

/* bug16a.c -- Nested inline function not expanded inline ("C" main program)
	Compile by:
	gcc -c bug16a.c
	Then compile and link bug16b.C (q.v.)
*/

void interface(const char* s);

int main() {
/*    interface("this is the string\n"); */
    interface__FPCc("this is the string\n");
    return 0;
}

------------ Source code (C++ subroutine)

/* bug16b.C -- Nested inline function not expanded inline

    To demonstrate:
	gcc -c bug16a.c
	g++ -c bug16b.C
	g++ bug16a.o bug16b.o
    Linker (collect2) complains that it can't find ___ls__FR7ostreamRC5zilch
		(operator << (ostream&, const zilch&) )
 */

#include <iostream.h>

class zilch {
  public:
    const char* content;
    zilch(const char* s) : content(s) { }
    friend ostream& operator << (ostream& f, const zilch& z)
	{ return f << z.content; }
    void print(ostream& f)
	{ f << *this; }		//Should expand op<< inline, but doesn't.
};

// Everything works if op << is out of line.
//ostream& operator << (ostream& f, const zilch& z)
//	{ return f << z.content; }

// Originally attributed to "extern C" and calling from "C" main program,
// but that turned out to be irrelevant.
/*extern "C"*/ void interface(const char* s) {
    zilch z(s);
    z.print(cout);
}
Technical Details
Message-ID: <9301042357.AA05967@malibu.pic.ucla.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!pic.ucla.edu!jimc

Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!pic.ucla.edu!jimc
From: jimc@pic.ucla.edu
Subject: g++ internal compiler error
Message-ID: <9301042357.AA05967@malibu.pic.ucla.edu>
Sender: gnulists@ai.mit.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Mon, 4 Jan 1993 07:57:08 GMT
Approved: bug-g++@prep.ai.mit.edu
Lines: 71