473,774 Members | 2,270 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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_ty pe_info::~__ver sioned_type_inf o()"

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
3 2855
tr**********@gm ail.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_ty pe_info::~__ver sioned_type_inf o()"

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

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
In article <11************ **********@b28g 2000cwb.googleg roups.com>,
<tr**********@g mail.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_t ype_info::~__ve rsioned_type_in fo()"

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
2436
by: Sony Antony | last post by:
I have the following simple program in Solaris Forte compiler 5.4 producing the warning. Though it produces the warning, it works fine as expected. This has been compiling fine without any warnings in the older 5.1 compiler. Since the latest compiler produces a warning, it makes me suspecious about my own code. I still cannot find any problems with it though. It essentially produces a warning whenever a copy constructor of a class with...
4
2034
by: Christopher M. Lusardi | last post by:
Hello, Can I run the subject line program using CC instead of cc? I attempted to use the "-c" option and it told me things were undefined. Isn't this CC option the same as the cc -c option? Thank you, Christopher Lusardi
1
1983
by: ninth | last post by:
in aix , when i compiler the code of db2 sample in 64 mode ,a error return. xlc -o db2mon db2mon.c tilapi.o -q64 -I/db2home/hnbas/sqllib/include -L/db2home/hnbas/sqllib/lib - ldb2 ld: 0711-317 ERROR: Undefined symbol: .sqleatin_api ld: 0711-317 ERROR: Undefined symbol: .sqlaintp_api ld: 0711-317 ERROR: Undefined symbol: .sqlmonsz ld: 0711-317 ERROR: Undefined symbol: .sqlmonss ld: 0711-317 ERROR: Undefined symbol: .sqlmrset ld:...
7
1090
by: Karl Ebener | last post by:
Hi! I have created a program using several classes with inheritage. When I compile and link, I get the following error: :$ g++ service2.cpp Service.cpp Application.cpp Message.cpp MessageQueue.cpp MessageFragmenter.cpp SingleMessage.cpp /tmp/ccsrT4jU.o(.gnu.linkonce.t._ZN9c_ServiceD1Ev+0xb): In function `c_Service::~c_Service ()': : undefined reference to `vtable for c_Service'
12
2685
by: Andrew Schepler | last post by:
When compiled with Visual C++ .NET 2003 (only), the program below aborts as though no matching catch clause is present. If the copy constructor of A is made public, it successfully catches the exception instead. If I step into __CxxThrowException in debug/assembly mode, it looks like the pThrowInfo parameter created by the compiler excluded typeid(A) from pCatchableTypeArray. It would be reasonable to fail to catch A by value because of the...
8
18052
by: pavan734 | last post by:
Hello, Please excuse me as Iam not posting this to correct group. I have a parser code obtained from flex command. I have many other files. When I compile them Iam getting a message like: undefined symbol yylex. What might have went wrong?
5
11360
by: druberego | last post by:
I read google and tried to find the solution myself. YES I do know that you can get undefined references if you: a) forget to implement the code for a prototype/header file item, or b) you forget to pass all the necessary object files to the linker. Neither of those are my problem. Please bear with me as the question I ask is rather long and I think it's beyond a CS101 level of linker stupidity. If it is a stupid CS101 mistake I'm making...
2
4368
by: zapr | last post by:
I am trying to compile on Mac OS X 10.4 my C program. I am stuck at the link phase where I get (gcc 4.01): $ gcc -s -Os -Wall -fprofile-arcs -fpack-struct -fno-common -ffast-math -ffloat-store -fno-strict-aliasing -fno-align-functions -fno-align-labels -fno-align-loops -fno-align-jumps -fsingle-precision-constant -nostdlib -nodefaultlibs -nostartfiles main.o -lpthread /Library/Frameworks/SDL.framework/Versions/A/SDL...
43
3836
by: JohnQ | last post by:
Are a default constructor, destructor, copy constructor and assignment operator generated by the compiler for a struct if they are not explicitely defined? I think the answer is yes, because "there is no difference between a struct and a class except the public/private access specification" (and a few minor other things). When I create a class, I always start by declaring the default constructor, copy constructor and assignment operator...
0
9621
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10267
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10040
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9914
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8939
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5355
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3611
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2852
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.