-
Frediano Ziglio authored
GCC gives this warning: .../plugin.hpp:103:7: warning: ‘class spice::streaming_agent::Agent’ has virtual functions and accessible non-virtual destructor [-Wnon-virtual-dtor] 103 | class Agent | ^~~~~ Although in this case is not an issue (the class is planned to be inherited only once and destructor not be called from base class) add virtual destructor. Declare protected to avoid plugins to call delete on the Agent. The destructor is declared at the end to avoid changing ABI. Currently we supported and released only GCC compiler where the vtable has this layout: Without the patch: RELOCATION RECORDS FOR [.data.rel.ro.local._ZTVN5spice15streaming_agent13ConcreteAgentE]: OFFSET TYPE VALUE 0000000000000008 R_X86_64_64 typeinfo for spice::streaming_agent::ConcreteAgent 0000000000000010 R_X86_64_64 spice::streaming_agent::ConcreteAgent::Register(std::shared_ptr<spice::streaming_agent::Plugin> const&) 0000000000000018 R_X86_64_64 spice::streaming_agent::ConcreteAgent::Options() const 0000000000000020 R_X86_64_64 spice::streaming_agent::ConcreteAgent::LogStat(char const*, ...) Destructor at the beginning of the class: RELOCATION RECORDS FOR [.data.rel.ro.local._ZTVN5spice15streaming_agent13ConcreteAgentE]: OFFSET TYPE VALUE 0000000000000008 R_X86_64_64 typeinfo for spice::streaming_agent::ConcreteAgent 0000000000000010 R_X86_64_64 spice::streaming_agent::ConcreteAgent::~ConcreteAgent() 0000000000000018 R_X86_64_64 spice::streaming_agent::ConcreteAgent::~ConcreteAgent() 0000000000000020 R_X86_64_64 spice::streaming_agent::ConcreteAgent::Register(std::shared_ptr<spice::streaming_agent::Plugin> const&) 0000000000000028 R_X86_64_64 spice::streaming_agent::ConcreteAgent::Options() const 0000000000000030 R_X86_64_64 spice::streaming_agent::ConcreteAgent::LogStat(char const*, ...) Destructor at the end of the class: RELOCATION RECORDS FOR [.data.rel.ro.local._ZTVN5spice15streaming_agent13ConcreteAgentE]: OFFSET TYPE VALUE 0000000000000008 R_X86_64_64 typeinfo for spice::streaming_agent::ConcreteAgent 0000000000000010 R_X86_64_64 spice::streaming_agent::ConcreteAgent::Register(std::shared_ptr<spice::streaming_agent::Plugin> const&) 0000000000000018 R_X86_64_64 spice::streaming_agent::ConcreteAgent::Options() const 0000000000000020 R_X86_64_64 spice::streaming_agent::ConcreteAgent::LogStat(char const*, ...) 0000000000000028 R_X86_64_64 spice::streaming_agent::ConcreteAgent::~ConcreteAgent() 0000000000000030 R_X86_64_64 spice::streaming_agent::ConcreteAgent::~ConcreteAgent() As you can see offsets do not change declaring destructor at the end while they change putting declaration at the beginning. Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Kevin Pouget <kpouget@redhat.com>
ae67c778