I googled "virtual functions but non-virtual destructor"

Ask for help regarding any technical issue or report any bug or OS independent issues.
Post Reply
MrDan
Peon
Peon
Posts: 34
Joined: 10 Jan 2008, 00:42
Location: Bay area , California

I googled "virtual functions but non-virtual destructor"

Post by MrDan »

Sorry, I tried to "google it" but am swimming (drowning) in a sea of useless results.

Getting the same error in different flavors.
|67|warning: `class PlayerIgnoreStrategy' has virtual functions but non-virtual destructor|
code for the problem section:
/**
* Ignore strategy: describes how we should handle ignores
*/
class
PlayerIgnoreStrategy
{
public:
std::string mDescription;
std::string mShortName;

/**
* Handle the ignoring of the indicated action by the indicated player
*/
virtual void ignore(Player *player, unsigned int flags) = 0;
};

Hey guys,
I actually built successfully a SVN client a while back then used the turtle svn to update and now can't get it to build anymore. (Using code::blocks) I updated guichan and also deleted the directory and re-Downloaded svn and attempted to build and now gets a lot farther but now gets the following errors.


C:\Program Files\The Mana World\SVN\branches\0.0\src\player_relations.h|67|warning: `class PlayerIgnoreStrategy' has virtual functions but non-virtual destructor|
C:\Program Files\The Mana World\SVN\branches\0.0\src\gui\..\player_relations.h|67|warning: `class PlayerIgnoreStrategy' has virtual functions but non-virtual destructor|
C:\Program Files\The Mana World\SVN\branches\0.0\src\gui\..\player_relations.h|67|warning: `class PlayerIgnoreStrategy' has virtual functions but non-virtual destructor|
C:\Program Files\The Mana World\SVN\branches\0.0\src\gui\..\player_relations.h|67|warning: `class PlayerIgnoreStrategy' has virtual functions but non-virtual destructor|
C:\Program Files\The Mana World\SVN\branches\0.0\src\player_relations.h|67|warning: `class PlayerIgnoreStrategy' has virtual functions but non-virtual destructor|
C:\Program Files\The Mana World\SVN\branches\0.0\src\net\..\player_relations.h|67|warning: `class PlayerIgnoreStrategy' has virtual functions but non-virtual destructor|
C:\Program Files\The Mana World\SVN\branches\0.0\src\net\..\player_relations.h|67|warning: `class PlayerIgnoreStrategy' has virtual functions but non-virtual destructor|
C:\Program Files\The Mana World\SVN\branches\0.0\src\net\..\player_relations.h|67|warning: `class PlayerIgnoreStrategy' has virtual functions but non-virtual destructor|
C:\Program Files\The Mana World\SVN\branches\0.0\src\player_relations.h|67|warning: `class PlayerIgnoreStrategy' has virtual functions but non-virtual destructor|
C:\Program Files\The Mana World\SVN\branches\0.0\src\player_relations.cpp|297|warning: `class PIS_nothing' has virtual functions but non-virtual destructor|
C:\Program Files\The Mana World\SVN\branches\0.0\src\player_relations.cpp|312|warning: `class PIS_dotdotdot' has virtual functions but non-virtual destructor|
C:\Program Files\The Mana World\SVN\branches\0.0\src\player_relations.cpp|352|warning: `class PIS_blinkname' has virtual functions but non-virtual destructor|
C:\Program Files\The Mana World\SVN\branches\0.0\src\player_relations.cpp|368|warning: `class PIS_emote' has virtual functions but non-virtual destructor|
||=== Build finished: 0 errors, 13 warnings ===|

Please help, and please don't beat me up for being a knave. :oops:
User avatar
fate
Warrior
Warrior
Posts: 402
Joined: 20 Mar 2008, 14:34

Re: I googled "virtual functions but non-virtual destructor"

Post by fate »

Hi,

these warnings are my fault, apologies for them! They should be harmless in practice; I have submitted a trivial patch (http://mantis.themanaworld.org/view.php?id=341) and would greatly appreciate if you could test whether it fixes these warnings! :-)

(Please note that (a) the warnings are harmless, to the best of my understanding, and (b) I cannot reproduce them locally, meaning that I cannot close this issue unless someone else can confirm that this patch helps.)

-- fate
MrDan
Peon
Peon
Posts: 34
Joined: 10 Jan 2008, 00:42
Location: Bay area , California

Re: I googled "virtual functions but non-virtual destructor"

Post by MrDan »

Yah, I think it did help now build log is much shorter: (missing files I think)

-------------- Build: default in The Mana World ---------------

WARNING: Can't read file's timestamp: C:\Program Files\The Mana World\SVN\branches\0.0\src\gui\popup_box.cpp
Linking executable: tmw.exe
mingw32-g++.exe: .objs\src\gui\popup_box.o: No such file or directory
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings
User avatar
Rotonen
TMW Adviser
TMW Adviser
Posts: 3154
Joined: 08 Sep 2004, 19:48
Location: Bern, Switzerland

Re: I googled "virtual functions but non-virtual destructor"

Post by Rotonen »

Still our policy of no warnings should apply.

The compiler developers do not go through the effort of coding in complex warning detections for nothing. Nor do the language level standardization committees define the language on vain basis on a whim.
This message used to be meaningful.
User avatar
fate
Warrior
Warrior
Posts: 402
Joined: 20 Mar 2008, 14:34

Re: I googled "virtual functions but non-virtual destructor"

Post by fate »

Rotonen,
  • g++ -Wall (g++ 4.3.1) did not give me those warnings. I have no compiler at my disposal that generates more warning messages. I cannot fix warnings that I do not see.
  • In fact, the warnings here were harmless; it is possible that g++ simply has a better error inference than whatever compiler was being used here and figured out that there was no point in flagging the matters we discussed. (Though I doubt that since that would require whole-program analysis, which no practical C++ compiler I know of performs-- the right thing for local analyses was indeed to be conservative and flag this as a potential problem.)
  • Where is the `no warnings' policy specified in detail? While this policy is common sense, I assume that you picked a reference compiler that is supposed not to generate warnings. If this compiler is not `the latest version of GCC's g++', I will make sure to test with it in the future.
MrDan-- thank you very much for reporting and testing! :-)

-- fate
User avatar
Rotonen
TMW Adviser
TMW Adviser
Posts: 3154
Joined: 08 Sep 2004, 19:48
Location: Bern, Switzerland

Re: I googled "virtual functions but non-virtual destructor"

Post by Rotonen »

AFAIK yes, latest GCC g++ is our reference.

Sorry for the automated response to warnings, did not really read through what gave the warnings.

At least I compile most of my code with -pedantic -Wall -Wextra so I am kind of nitpicky about warnings. Although I am more of an lower level coder with C99 and Fortran95 and hence cannot directly apply my expertise here.
This message used to be meaningful.
User avatar
fate
Warrior
Warrior
Posts: 402
Joined: 20 Mar 2008, 14:34

Re: I googled "virtual functions but non-virtual destructor"

Post by fate »

Rotonen,

Thank you! `-pedantic -Wextra' might indeed have helped here. I will keep this in mind for the future. :-)

(No, I don't normally do C++.)

-- fate
Post Reply