This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: g++ bug ?


The following message is a courtesy copy of an article
that has been posted to gnu.gcc.help,mcom.linux as well.

Arun Sharma <asharma@nospam.netscape.com> writes:

> I have a bunch of files which compiled fine with gcc-2.7.2.1 on a
> Redhat Linux 4.2 system. I upgraded to Redhat 5.0 recently, which has
> a gcc-2.7.2.3 and am finding a whole bunch of linker errors.
> 
> The linker errors are due to undefined references to inline
> methods. Does anyone know if this is a bug ? Has it been fixed in more
> recent releases ? I'm also using -fhandle-exceptions if that is of any
> help. 
> 
> 	-Arun
> 

After some investigation, I discovered that removal of certain virtual
functions in the class in question fixes the errors.

class foo {

	method() { /* definition */ };
	virtual v1();
	virtual v2();
}

class foo1 : public class foo {
	/* other stuff */
}

class foo2 : public class foo {
	/* other stuff */
}

// C++ file

foo f1;
foo1 f2;
foo2 f3;

// results in a function call - hence linker errors
f1.method();
// Inlined - as it should be 
f2.method();
// Inlined - as it should be
f3.method();

Removal of v1 and v2 from class foo fixes the errors - all calls to
method() are inlined. This bug exists in gcc-2.7.2.3 and egcs-1.0.

	-Arun


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]