Boost C++ Libraries: Ticket #8726: GCC 4.8 warns of variable set but not used https://svn.boost.org/trac10/ticket/8726 <p> When compiling with -Wall (GCC 4.8.0) the following warning is raised as an error: </p> <pre class="wiki">libs/serialization/src/basic_iarchive.cpp: In member function ‘const boost::archive::detail::basic_pointer_iserializer* boost::archive::detail::basic_iarchive_impl::load_pointer(boost::archive::detail::basic_iarchive&amp;, void*&amp;, const boost::archive::detail::basic_pointer_iserializer*, const boost::archive::detail::basic_pointer_iserializer* (*)(const boost::serialization::extended_type_info&amp;))’: libs/serialization/src/basic_iarchive.cpp:455:23: error: variable ‘new_cid’ set but not used [-Werror=unused-but-set-variable] class_id_type new_cid = register_type(bpis_ptr-&gt;get_basic_serializer()); </pre><p> <em>new_cid</em> is only used to perform a BOOST_ASSERT, maybe this could be collapsed into one line? </p> <pre class="wiki">Index: libs/serialization/src/basic_iarchive.cpp =================================================================== --- libs/serialization/src/basic_iarchive.cpp (revision 84899) +++ libs/serialization/src/basic_iarchive.cpp (working copy) @@ -452,10 +452,9 @@ bpis_ptr = (*finder)(*eti); } BOOST_ASSERT(NULL != bpis_ptr); - class_id_type new_cid = register_type(bpis_ptr-&gt;get_basic_serializer()); + BOOST_ASSERT(register_type(bpis_ptr-&gt;get_basic_serializer()) == cid); int i = cid; cobject_id_vector[i].bpis_ptr = bpis_ptr; - BOOST_ASSERT(new_cid == cid); } int i = cid; cobject_id &amp; co = cobject_id_vector[i]; </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8726 Trac 1.4.3 Robert Ramey Tue, 20 Aug 2013 22:15:06 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/8726#comment:1 https://svn.boost.org/trac10/ticket/8726#comment:1 <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> Hmmm - this wouldn't work. </p> <p> It would mean that when compiling for release mode, the register_type function wouldn't get called. </p> <p> Note that this will only emit the warning in debug mode. </p> <p> I'm going to mark this idea as not valid - feel free to re-open if if you get a better idea. </p> <p> RObert Ramey </p> Ticket Chris Stylianou <chris5287@…> Tue, 20 Aug 2013 22:40:00 GMT status changed; resolution deleted https://svn.boost.org/trac10/ticket/8726#comment:2 https://svn.boost.org/trac10/ticket/8726#comment:2 <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> <p> True, but it would still be nice to silence the unused warning. Could you use BOOST_VERIFY instead of BOOST_ASSERT? </p> Ticket Robert Ramey Wed, 21 Aug 2013 03:32:46 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/8726#comment:3 https://svn.boost.org/trac10/ticket/8726#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> Ok _ i patched this. Subject to test </p> Ticket Chris Stylianou <chris5287@…> Wed, 21 Aug 2013 17:57:32 GMT <link>https://svn.boost.org/trac10/ticket/8726#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8726#comment:4</guid> <description> <p> Great, could you post a link to the changeset when it has been done. </p> </description> <category>Ticket</category> </item> <item> <author>Chris Stylianou <chris5287@…></author> <pubDate>Fri, 30 Aug 2013 08:35:34 GMT</pubDate> <title>status changed; resolution deleted https://svn.boost.org/trac10/ticket/8726#comment:5 https://svn.boost.org/trac10/ticket/8726#comment:5 <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">fixed</span> </li> </ul> <p> Still awaiting changeset, could this be closed only once the changeset has been committed and linked here. </p> Ticket Jeremiah Willcock Thu, 17 Oct 2013 22:58:31 GMT attachment set https://svn.boost.org/trac10/ticket/8726 https://svn.boost.org/trac10/ticket/8726 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">8726_simpler_patch.patch</span> </li> </ul> <p> Minimal patch to fix warning </p> Ticket Jeremiah Willcock Thu, 17 Oct 2013 22:59:19 GMT <link>https://svn.boost.org/trac10/ticket/8726#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8726#comment:6</guid> <description> <p> I have attached a simpler patch; this version is unlikely to break anything else since it only adds a cast to <code>void</code> to avoid the warning. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Robert Ramey</dc:creator> <pubDate>Tue, 18 Feb 2014 18:25:22 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/8726#comment:7 https://svn.boost.org/trac10/ticket/8726#comment:7 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> fixed in next release </p> Ticket