473,386 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

gcc warnings again

warning: 'class gdt_manager' has virtual functions but non-virtual
destructor

what does this mean? how to fix it?

thanks.

Jun 26 '06 #1
12 1281
asdf wrote:
warning: 'class gdt_manager' has virtual functions but non-virtual
destructor

what does this mean? how to fix it?


http://www.parashift.com/c++-faq-lit....html#faq-20.7
"When should my destructor be virtual?"

Answer: Always, unless you find a reason to take the virtual out.

--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
Jun 26 '06 #2
asdf wrote:
warning: 'class gdt_manager' has virtual functions but non-virtual
destructor

what does this mean?
That the class gdt_manager has virtual functions but non-virtual destructor.
how to fix it?


By making its destructor virtual.

Jun 26 '06 #3

warnings are not equal to error. you should make destructor virtual.
but not must

Jun 26 '06 #4

海风 wrote:
warnings are not equal to error. you should make destructor virtual.
but not must


destructors should always be virtual functions in order to properly get
invoked.

Jun 26 '06 #5
zj****@gmail.com wrote:

海风 wrote:
warnings are not equal to error. you should make destructor virtual.
but not must


destructors should always be virtual functions in order to properly get
invoked.


Only if the object is destroyed polymorphically.

Jun 26 '06 #6
Rolf Magnus wrote:
zj****@gmail.com wrote:
海风 wrote:
warnings are not equal to error. you should make destructor virtual.
but not must

destructors should always be virtual functions in order to properly get
invoked.


Only if the object is destroyed polymorphically.


Yep. On my current project, I'm fighting the "all destructors must be
virtual" directive, on the grounds that we don't actually do any dynamic
allocation, and therefore a virtual destructor is unnecessary.
Jun 26 '06 #7
red floyd wrote:
Rolf Magnus wrote:
zj****@gmail.com wrote:
海风 wrote:

warnings are not equal to error. you should make destructor virtual.
but not must

destructors should always be virtual functions in order to properly get
invoked.

Only if the object is destroyed polymorphically.

Yep. On my current project, I'm fighting the "all destructors must be
virtual" directive, on the grounds that we don't actually do any dynamic
allocation, and therefore a virtual destructor is unnecessary.


What's the harm in making the destructor virtual?

Joe
Jun 26 '06 #8
* zj****@gmail.com:
?? wrote:
warnings are not equal to error. you should make destructor virtual.
but not must


destructors should always be virtual functions in order to properly get
invoked.


Too bad the standard library's classes generally don't have virtual
destructors. Unusable. Oh well.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jun 26 '06 #9
Joe Van Dyk wrote:
[..]
What's the harm in making the destructor virtual?


You mean, besides potential performance hindrance?
Jun 26 '06 #10

warnings are not equal to error. you should make destructor virtual.
but not must


use virtual to make sure the destructor will be excuted, but it costs a
pointer in vtbl.
Jun 27 '06 #11
"William" <wi*****@xxx.com> writes:

warnings are not equal to error. you should make destructor virtual.
but not must


use virtual to make sure the destructor will be excuted, but it costs a
pointer in vtbl.


Unless you are working under SEVERE memory constraints (e.g. in an embedded
system) this is a non-issue since there is only one vtbl per class with
virtual functions.

Jun 28 '06 #12
In article <xv*************@Psilocybe.Update.UU.SE>,
jo****@Student.DoCS.UU.SE says...

[ ... ]
Unless you are working under SEVERE memory constraints (e.g. in an embedded
system) this is a non-issue since there is only one vtbl per class with
virtual functions.


Any virtual function also (typically) means that each object has to
carry a pointer to the vtable. In some cases that's simply
unacceptable -- consider (for example) building a text editor, and
wrapping each character in a class. The total size of the class sans
virtual dtor is typically 8 bits. On a 64-bit system, the vtable
pointer would increase that to 72 bits, and that might easily cause
padding to be added, so the total size goes up to 128 bits.

Mulitply that overhead by the number of characters in a text file,
and you've got a text editor almost as efficient as emacs on an 8-bit
microcontroller.

--
Later,
Jerry.

The universe is a figment of its own imagination.
Jun 29 '06 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Gary | last post by:
Hi! guys, I have a SQL agent job fails because it gets 10 warnings when it runs a stored procedure. These warnings are trivial and can be ignored. Can I make it ignore these warnings and...
20
by: News | last post by:
I'm new to c and gcc. I was wondering if anyone can point me to a web page or book that has a list of the warning messages and their meanings. Are the warnings the same no matter what compiler...
5
by: rawCoder | last post by:
Hi All, In Visual Basic .NET , your function definition might requirre you to return a value but (accidently/intentionally) you dont put any 'return value' in the function. In this case VB...
5
by: Lindsay | last post by:
I'm getting some strange warnings when I compile: pointer truncation from 'HMENU' to 'unsigned int' The line in question is: AppendMenu(hMenu,MF_STRING|MF_POPUP,UINT(hStyle),"Style"); (where...
3
by: tony | last post by:
Hello!! I use VS 2003 and C# for all class library except MeltPracCommon.dll which is C++.NET The problem is that I get these warnings when building the exe file and use my class libraries....
6
by: aioe.cjb.net | last post by:
So, I was planning on ridding my VS2005 solution of all warnings, but the ones sounding "The variable 'ex' is declared but never used" in catch-blocks, are causing a headache. I have several...
16
by: RichardP | last post by:
Hi there everyone - I'm new to this forum. I am having an issue when running an application from an instance of Access which has been started through automation (early or late bound, makes no...
2
by: Sergei Shelukhin | last post by:
Hi. I need to handle warnings in incorrect regular expressions executed using preg_match. Warnings shouldn't appear, instead I want to output some generic message like: "Bad regex: $regex" and...
3
by: gil | last post by:
Hi, I'm trying to find the best way to work with compiler warnings. I'd like to remove *all* warnings from the code, and playing around with the warning level, I've noticed that compiling with...
51
by: jacob navia | last post by:
After a user asked for clarification about some warnings issued by lcc-win, I have updated the compiler to reflect this discussion. 1) The buggy warning about long l; printf("%li", l * 10L);...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...

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.