-Wnon-virtual-dtor
is the name of the specific warning that is turned on by -Weffc++
. To turn any warning into an error, you use -Werror=...
. So if the warning were -Wspam
, making it into an error would be -Werror=spam
. So in this case, you would use -Werror=non-virtual-dtor
.
However, I don't feel that this warning is especially useful if you are on GCC 4.8 and up. Then you have access to the superior -Wdelete-non-virtual-dtor
:
Warn when delete
is used to destroy an instance of a class that
has virtual functions and non-virtual destructor. It is unsafe to
delete an instance of a derived class through a pointer to a base
class if the base class does not have a virtual destructor. This
warning is enabled by -Wall
.
Note that g++ -Wspam -Werror=spam
is the same thing as g++ -Werror=spam
. Turning a warning into an error automatically turns that warning on.
On a related note, you're not the only one who thinks that -Weffc++
is a little overzealous.