By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,238 Members | 1,804 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,238 IT Pros & Developers. It's quick & easy.

Compiler adds undefined symbol reference for virtual functions....

P: n/a
Hi

I am trying to compile a quite large software system with a new
compiler. During that attempt I am facing problems during the link
phase, and I have traced it down to the following construct:

test.cc:
class Foo
{
public:
virtual ~Foo();
};

class Bar : public Foo
{
public:
virtual ~Bar() {};
};

If I compile this unit all of the previous compilers I have tried will
generate _no_ symbols, since I don't actually use anything here. The
new compiler I have tried gives me:

Undefined symbols from test.o:
typeid<Foo>
Foo::~Foo()
Class tables [Vtable] dependent on key function:
"__versioned_type_info::~__versioned_type_info ()"

So the question is as simple as: Is this a "bug" in the new compiler I
have used, or is it "allowed" to do this according to the
specification...

(In my "real" program the classes reside in separate header files
included by a lot of different "modules" in my system...)

Trond

Sep 29 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
tr**********@gmail.com wrote:
I am trying to compile a quite large software system with a new
compiler. During that attempt I am facing problems during the link
phase, and I have traced it down to the following construct:

test.cc:
class Foo
{
public:
virtual ~Foo();
A virtual function will be defined or declared pure or both. You
cannot declare a function virtual without providing its definition
somewhere. Period.
};

class Bar : public Foo
{
public:
virtual ~Bar() {};
};

If I compile this unit all of the previous compilers I have tried will
generate _no_ symbols, since I don't actually use anything here. The
new compiler I have tried gives me:

Undefined symbols from test.o:
typeid<Foo>
Foo::~Foo()
Class tables [Vtable] dependent on key function:
"__versioned_type_info::~__versioned_type_info ()"

So the question is as simple as: Is this a "bug" in the new compiler I
have used, or is it "allowed" to do this according to the
specification...
It is not allowed to have a virtual function that is not pure without
a definition. You can only omit the definition of a virtual function
iff you declare it pure.
(In my "real" program the classes reside in separate header files
included by a lot of different "modules" in my system...)
That doesn't matter.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Sep 29 '06 #2

P: n/a

Victor Bazarov wrote:
So the question is as simple as: Is this a "bug" in the new compiler I
have used, or is it "allowed" to do this according to the
specification...

It is not allowed to have a virtual function that is not pure without
a definition. You can only omit the definition of a virtual function
iff you declare it pure.
(In my "real" program the classes reside in separate header files
included by a lot of different "modules" in my system...)

That doesn't matter.
This was _exactly_ the kind of information I was looking for :-)

regards,

Trond

Sep 29 '06 #3

P: n/a
In article <11**********************@b28g2000cwb.googlegroups .com>,
<tr**********@gmail.comwrote:
>I am trying to compile a quite large software system with a new
compiler. During that attempt I am facing problems during the link
phase, and I have traced it down to the following construct:

test.cc:
class Foo
{
public:
virtual ~Foo();
};

class Bar : public Foo
{
public:
virtual ~Bar() {};
};

If I compile this unit all of the previous compilers I have tried will
generate _no_ symbols, since I don't actually use anything here. The
new compiler I have tried gives me:

Undefined symbols from test.o:
typeid<Foo>
Foo::~Foo()
Class tables [Vtable] dependent on key function:
"__versioned_type_info::~__versioned_type_info( )"

So the question is as simple as: Is this a "bug" in the new compiler I
have used, or is it "allowed" to do this according to the
specification...

(In my "real" program the classes reside in separate header files
included by a lot of different "modules" in my system...)
I don't have my standard in front of me, but I'm fairly
certain that it says that the virtuals need to be defined
but that a diagnostic is not required.
--
Greg Comeau / 20 years of Comeauity! Intel Mac Port now in alpha!
Comeau C/C++ ONLINE == http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
Sep 29 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.