Boost C++ Libraries: Ticket #6824: warning: delete called on boost::error_info... that has virtual functions but non-virtual destructor https://svn.boost.org/trac10/ticket/6824 <p> When compiling boost 1.49.0 thread.hpp with clang with -Wall, I receive warnings: </p> <p> /Users/richardpowell/boost/include/boost/checked_delete.hpp:34:5: warning: delete called on </p> <blockquote> <p> 'boost::error_info&lt;boost::tag_original_exception_type, const std::type_info *&gt;' that has virtual functions but non-virtual destructor [-Wdelete-non-virtual-dtor] </p> </blockquote> <blockquote> <p> delete x; </p> </blockquote> <p> =-=-= </p> <p> More details: </p> <p> $ cat test2.cpp #include &lt;boost/thread.hpp&gt; </p> <p> $ clang++ --version Apple clang version 4.0 (tags/Apple/clang-421.0.11) (based on LLVM 3.1svn) Target: x86_64-apple-darwin11.3.0 Thread model: posix </p> <p> $ clang++ -g -I. -Wall -I ~/boost/include -c test2.cpp In file included from test2.cpp:1: In file included from /Users/richardpowell/boost/include/boost/thread.hpp:13: In file included from /Users/richardpowell/boost/include/boost/thread/thread.hpp:17: In file included from /Users/richardpowell/boost/include/boost/thread/pthread/thread_data.hpp:10: In file included from /Users/richardpowell/boost/include/boost/shared_ptr.hpp:17: In file included from /Users/richardpowell/boost/include/boost/smart_ptr/shared_ptr.hpp:30: /Users/richardpowell/boost/include/boost/checked_delete.hpp:34:5: warning: delete called on </p> <blockquote> <p> 'boost::error_info&lt;boost::tag_original_exception_type, const std::type_info *&gt;' that has virtual functions but non-virtual destructor [-Wdelete-non-virtual-dtor] </p> </blockquote> <blockquote> <p> delete x; <sup> </sup></p> </blockquote> <p> /Users/richardpowell/boost/include/boost/smart_ptr/detail/shared_count.hpp:95:13: note: in instantiation of function template specialization </p> <blockquote> <p> 'boost::checked_delete&lt;boost::error_info&lt;boost::tag_original_exception_type, const std::type_info *&gt; &gt;' requested here </p> <blockquote> <p> boost::checked_delete( p ); <sup> </sup></p> </blockquote> </blockquote> <p> /Users/richardpowell/boost/include/boost/smart_ptr/shared_ptr.hpp:183:44: note: in instantiation of function template specialization </p> <blockquote> <p> 'boost::detail::shared_count::shared_count&lt;boost::error_info&lt;boost::tag_original_exception_type, const std::type_info *&gt; &gt;' requested here </p> </blockquote> <blockquote> <p> explicit shared_ptr( Y * p ): px( p ), pn( p ) <em> Y must be complete </em></p> <blockquote> <p> <sup> </sup></p> </blockquote> </blockquote> <p> /Users/richardpowell/boost/include/boost/exception/info.hpp:170:42: note: in instantiation of function template specialization </p> <blockquote> <p> 'boost::shared_ptr&lt;boost::error_info&lt;boost::tag_original_exception_type, const std::type_info *&gt; </p> <blockquote class="citation"> <p> ::shared_ptr&lt;boost::error_info&lt;boost::tag_original_exception_type, const std::type_info *&gt; &gt;' requested here </p> </blockquote> <blockquote> <p> shared_ptr&lt;error_info_tag_t&gt; p( new error_info_tag_t(v) ); </p> <blockquote> <p> <sup> </sup></p> </blockquote> </blockquote> </blockquote> <p> /Users/richardpowell/boost/include/boost/exception/info.hpp:191:16: note: in instantiation of function template specialization </p> <blockquote> <p> 'boost::exception_detail::set_info&lt;boost::unknown_exception, boost::tag_original_exception_type, const std::type_info *&gt;' requested here </p> <blockquote> <p> return exception_detail::set_info(x,v); </p> <blockquote> <p> <sup> </sup></p> </blockquote> </blockquote> </blockquote> <p> /Users/richardpowell/boost/include/boost/exception/detail/exception_ptr.hpp:181:21: note: in instantiation of function template specialization </p> <blockquote> <p> 'boost::operator&lt;&lt;&lt;boost::unknown_exception, boost::tag_original_exception_type, const std::type_info *&gt;' requested here </p> <blockquote> <p> (*this) &lt;&lt; original_exception_type(&amp;typeid(e)); </p> <blockquote> <p> <sup> </sup></p> </blockquote> </blockquote> </blockquote> <p> /Users/richardpowell/boost/include/boost/exception/detail/exception_ptr.hpp:160:13: note: in instantiation of function template specialization </p> <blockquote> <p> 'boost::unknown_exception::add_original_type&lt;std::exception&gt;' requested here </p> <blockquote> <p> add_original_type(e); <sup> </sup></p> </blockquote> </blockquote> <p> 1 warning generated. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6824 Trac 1.4.3 ph03@… Fri, 04 May 2012 03:41:33 GMT <link>https://svn.boost.org/trac10/ticket/6824#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6824#comment:1</guid> <description> <p> I have exactly the same warning with </p> <p> $clang -v clang version 3.2 (trunk) Target: x86_64-pc-linux-gnu Thread model: posix . Shouldn't be too hard to fix, am I wrong? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Mon, 28 May 2012 15:58:15 GMT</pubDate> <title>owner, component changed https://svn.boost.org/trac10/ticket/6824#comment:2 https://svn.boost.org/trac10/ticket/6824#comment:2 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Anthony Williams</span> to <span class="trac-author">Emil Dotchevski</span> </li> <li><strong>component</strong> <span class="trac-field-old">thread</span> → <span class="trac-field-new">exception</span> </li> </ul> <p> I think that this issue has been fixed on Boost.Exception. </p> Ticket anonymous Tue, 29 May 2012 12:06:59 GMT <link>https://svn.boost.org/trac10/ticket/6824#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6824#comment:3</guid> <description> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6873" title="#6873: Bugs: g++-4.7.0 warns about non-virtual destructor when -Wall (closed: duplicate)">#6873</a> is a dupe with a different compiler, it should be reassigned also. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Thu, 05 Jul 2012 13:28:12 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6824#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6824#comment:4</guid> <description> <p> this issue is fixed in 1.50 by adding "virtual" at error_info_impl.hpp:33, the same fix I used to make my production builds work, so of course I'm happy with it ;-). </p> <p> this ticket and <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6873" title="#6873: Bugs: g++-4.7.0 warns about non-virtual destructor when -Wall (closed: duplicate)">#6873</a> should be closed. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Braunne</dc:creator> <pubDate>Fri, 06 Jun 2014 17:18:28 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6824#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6824#comment:5</guid> <description> <p> For some reason, this fix did not work on my boost 1.47. Any ideas? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Emil Dotchevski</dc:creator> <pubDate>Fri, 06 Jun 2014 18:14:45 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6824#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6824#comment:6</guid> <description> <p> Which fix? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Fri, 06 Jun 2014 20:02:33 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6824#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6824#comment:7</guid> <description> <p> Making the error_info_base destructor virtual </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Fri, 06 Jun 2014 20:10:25 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6824#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6824#comment:8</guid> <description> <p> I'm using GCC 4.8. and this is the warning I'm getting: </p> <p> .../boost/checked_delete.hpp:34:5: warning: deleting object of polymorphic class type 'safe::<a class="missing wiki">SetFeatureUseOp</a>' which has non-virtual destructor might cause undefined behaviour [-Wdelete-non-virtual-dtor] </p> <blockquote> <p> delete x; <sup> </sup></p> </blockquote> </description> <category>Ticket</category> </item> <item> <dc:creator>Emil Dotchevski</dc:creator> <pubDate>Fri, 06 Jun 2014 20:13:36 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/6824#comment:9 https://svn.boost.org/trac10/ticket/6824#comment:9 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> <p> What does safe::<a class="missing wiki">SetFeatureUseOp</a> have to do with Boost? </p> Ticket anonymous Fri, 06 Jun 2014 20:34:57 GMT <link>https://svn.boost.org/trac10/ticket/6824#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6824#comment:10</guid> <description> <p> I really appreciate your desire to help. </p> <pre class="wiki">In file included from .../boost/smart_ptr/shared_ptr.hpp:30:0, from .../boost/shared_ptr.hpp:17, from safeFeatureKeyTests.cc:17: .../boost/checked_delete.hpp: In instantiation of 'void boost::checked_delete(T*) [with T = safe::SetFeatureUseOp]': .../boost/smart_ptr/detail/shared_count.hpp:95:38: required from 'boost::detail::shared_count::shared_count(Y*) [with Y = safe::SetFeatureUseOp]' .../boost/smart_ptr/shared_ptr.hpp:183:50: required from 'boost::shared_ptr&lt;T&gt;::shared_ptr(Y*) [with Y = safe::SetFeatureUseOp; T = safe::TestOperation]' safeFeatureKeyTests.cc:452:9: required from here .../boost/checked_delete.hpp:34:5: warning: deleting object of polymorphic class type 'safe::SetFeatureUseOp' which has non-virtual destructor might cause undefined behaviour [-Wdelete-non-virtual-dtor] delete x; ^ </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Fri, 06 Jun 2014 21:09:35 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6824#comment:11 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6824#comment:11</guid> <description> <p> Maybe I lack the required understanding to resolve that issue, but upon first inspection it did seem like a boost issue. Agree? </p> </description> <category>Ticket</category> </item> <item> <author>sppande@…</author> <pubDate>Mon, 25 Aug 2014 02:52:14 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6824#comment:12 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6824#comment:12</guid> <description> <p> did anybody found the resolution for the issue mentioned in the above comment. After resolving bunch of issues i am stuck with this one, although i am on latest version of boost 1_56. any advice/suggestion would be great help. </p> <p> Thanks, Shail </p> </description> <category>Ticket</category> </item> <item> <author>sppande@…</author> <pubDate>Mon, 25 Aug 2014 02:53:30 GMT</pubDate> <title>status changed; resolution deleted https://svn.boost.org/trac10/ticket/6824#comment:13 https://svn.boost.org/trac10/ticket/6824#comment:13 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">invalid</span> </li> </ul> Ticket anonymous Mon, 25 Aug 2014 02:56:35 GMT version changed https://svn.boost.org/trac10/ticket/6824#comment:14 https://svn.boost.org/trac10/ticket/6824#comment:14 <ul> <li><strong>version</strong> <span class="trac-field-old">Boost 1.49.0</span> → <span class="trac-field-new">Boost 1.56.0</span> </li> </ul> Ticket Emil Dotchevski Mon, 25 Aug 2014 06:08:42 GMT <link>https://svn.boost.org/trac10/ticket/6824#comment:15 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6824#comment:15</guid> <description> <p> The lack of virtual destructor is by design, however the warning should not be happening. May I have compiler version and exact command line please? </p> </description> <category>Ticket</category> </item> <item> <author>sppande@…</author> <pubDate>Mon, 25 Aug 2014 06:21:22 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6824#comment:16 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6824#comment:16</guid> <description> <p> i am using gcc 4.7.2 on centos 6.5 i am getting this error when (ironbee) <strong>make</strong> command compiles files using gcc. </p> <p> command looks like below </p> <p> g++ -DFAVE_CONFIG_H -I/opt/boost_1_56_0/include -g -02 -pthread -MT ee.o -MD -MP -MF .deps/ee.Tpo -c -o ee.o ee.cpp </p> <p> not sure if this helps much. Thanks for your quick response. </p> <p> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Steven Watanabe</dc:creator> <pubDate>Fri, 27 Feb 2015 22:09:52 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6824#comment:17 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6824#comment:17</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/6824#comment:10" title="Comment 10">anonymous</a>: </p> <blockquote class="citation"> <p> I really appreciate your desire to help. </p> <pre class="wiki">In file included from .../boost/smart_ptr/shared_ptr.hpp:30:0, from .../boost/shared_ptr.hpp:17, from safeFeatureKeyTests.cc:17: .../boost/checked_delete.hpp: In instantiation of 'void boost::checked_delete(T*) [with T = safe::SetFeatureUseOp]': .../boost/smart_ptr/detail/shared_count.hpp:95:38: required from 'boost::detail::shared_count::shared_count(Y*) [with Y = safe::SetFeatureUseOp]' .../boost/smart_ptr/shared_ptr.hpp:183:50: required from 'boost::shared_ptr&lt;T&gt;::shared_ptr(Y*) [with Y = safe::SetFeatureUseOp; T = safe::TestOperation]' safeFeatureKeyTests.cc:452:9: required from here .../boost/checked_delete.hpp:34:5: warning: deleting object of polymorphic class type 'safe::SetFeatureUseOp' which has non-virtual destructor might cause undefined behaviour [-Wdelete-non-virtual-dtor] delete x; ^ </pre></blockquote> <p> This is not a Boost issue. The error message only appears inside Boost because boost::shared_ptr has to call delete. The class that is causing the warning is not related to Boost in any way. </p> </description> <category>Ticket</category> </item> </channel> </rss>