[variant] static_visitor has no virtual destructor.

Hello, I have a compilation error with Boost (1.52) and g++ (4.7) with the flag -Weffc++: error: base class ‘class boost::static_visitor<std::basic_string<char>
’ has a non-virtual destructor [-Werror=effc++]
And the static_visitor class is defined with a protected non-virtual destructor: template <typename R = ::boost::detail::static_visitor_default_return> class static_visitor : public detail::is_static_visitor_tag { public: // typedefs typedef R result_type; protected: // for use as base class only static_visitor() { } ~static_visitor() { } }; Is it normal ? And if it is, how to avoid this error ? Thank you for your help, Pierre Talbot.

2012/11/7 Pierre Talbot <ptalbot@mopong.net>
Hello,
I have a compilation error with Boost (1.52) and g++ (4.7) with the flag -Weffc++:
error: base class ‘class boost::static_visitor<std::**basic_string<char>
’ has a non-virtual destructor [-Werror=effc++]
And the static_visitor class is defined with a protected non-virtual destructor:
template <typename R = ::boost::detail::static_**visitor_default_return> class static_visitor : public detail::is_static_visitor_tag { public: // typedefs
typedef R result_type;
protected: // for use as base class only
static_visitor() { } ~static_visitor() { }
};
Is it normal ? And if it is, how to avoid this error ?
Thank you for your help,
Pierre Talbot.
I think your compiler is wrong about this. Please see "Guideline #4: A base class destructor should be either public and virtual, or protected and nonvirtual." [1] ;-) HTH, Kris [1] http://www.gotw.ca/publications/mill18.htm

On 11/07/2012 07:40 PM, Krzysztof Czainski wrote:
I think your compiler is wrong about this. Please see "Guideline #4: A base class destructor should be either public and virtual, or protected and nonvirtual." [1] ;-)
HTH, Kris
Thank you, I'll read it carefully. Pierre T.

AMDG On 11/07/2012 10:30 AM, Pierre Talbot wrote:
Hello,
I have a compilation error with Boost (1.52) and g++ (4.7) with the flag -Weffc++:
I would strongly advise against using this flag with Boost. For large parts of Boost, the rules that -Weffc++ checks are simply not applicable, and trying to comply with them would be a huge burden for no gain.
error: base class ‘class boost::static_visitor<std::basic_string<char>
’ has a non-virtual destructor [-Werror=effc++]
And the static_visitor class is defined with a protected non-virtual destructor:
template <typename R = ::boost::detail::static_visitor_default_return> class static_visitor : public detail::is_static_visitor_tag { public: // typedefs
typedef R result_type;
protected: // for use as base class only
static_visitor() { } ~static_visitor() { }
};
Is it normal ? And if it is, how to avoid this error ?
In Christ, Steven Watanabe
participants (3)
-
Krzysztof Czainski
-
Pierre Talbot
-
Steven Watanabe