Boost C++ Libraries: Ticket #3216: variable shadowing with possibly bad implications https://svn.boost.org/trac10/ticket/3216 <p> we usually compile our code with -Wshadow using gcc; this usually reports lots of shadowing in the boost headers. Most of this is just annoying noise, but I've found one issue in the file boost_1_39_0/boost/asio/detail/reactive_socket_service.hpp where the name "ec" is used first as a reference parameter and then redeclared and used as a local variable. It seems to me that some of the uses after this point may have intended to save state back in the reference variable, so this code should be carefully reviewed. At the very least, some better variable names should be chosen so it's clear what the intended logic was. </p> <p> I have a patch that renames both "ec" variables without changing the semantics of the code (attached). </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3216 Trac 1.4.3 Arne Juul <arnej@…> Wed, 24 Jun 2009 14:29:11 GMT attachment set https://svn.boost.org/trac10/ticket/3216 https://svn.boost.org/trac10/ticket/3216 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">ec-rename.patch</span> </li> </ul> <p> patch </p> Ticket Steven Watanabe Wed, 24 Jun 2009 19:58:07 GMT component changed; owner set https://svn.boost.org/trac10/ticket/3216#comment:1 https://svn.boost.org/trac10/ticket/3216#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">chris_kohlhoff</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">asio</span> </li> </ul> Ticket Arne Juul <arnej@…> Thu, 25 Jun 2009 14:39:03 GMT attachment set https://svn.boost.org/trac10/ticket/3216 https://svn.boost.org/trac10/ticket/3216 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">shadow-patches.txt</span> </li> </ul> <p> Here's more patches that just renames variables to make -Wshadow silent. </p> Ticket chris_kohlhoff Fri, 26 Jun 2009 13:56:24 GMT status changed https://svn.boost.org/trac10/ticket/3216#comment:2 https://svn.boost.org/trac10/ticket/3216#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> <p> Fixed on trunk in changeset <a class="changeset" href="https://svn.boost.org/trac10/changeset/54377" title="Remove a local variable that was hiding the ec parameter and ...">[54377]</a>. </p> Ticket chris_kohlhoff Mon, 29 Jun 2009 13:36:17 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/3216#comment:3 https://svn.boost.org/trac10/ticket/3216#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/54499" title="Merge from trunk. Fixes #3095, #3216, #3098, #3107, #1341, #2754, ...">[54499]</a>) Merge from trunk. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3095" title="#3095: Bugs: bug in automatic resizing of the bucket array (closed: fixed)">#3095</a>, <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3216" title="#3216: Bugs: variable shadowing with possibly bad implications (closed: fixed)">#3216</a>, <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3098" title="#3098: Bugs: Abort in boost::asio::ip::tcp::acceptor constructor on Mac OS X (closed: fixed)">#3098</a>, <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3107" title="#3107: Bugs: Error in allocation/dealocation of timers (closed: fixed)">#3107</a>, <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/1341" title="#1341: Patches: unused argument and another g++ warning (closed: fixed)">#1341</a>, <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2754" title="#2754: Patches: [PATCH] building asio without exception support (closed: fixed)">#2754</a>, <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3157" title="#3157: Support Requests: ASIO Reference has no header file information (closed: fixed)">#3157</a>, <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2620" title="#2620: Bugs: Missing entries in documentation index (closed: fixed)">#2620</a>, <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2618" title="#2618: Bugs: Warnings about unused parameters with g++ -Wunused-parameter (closed: fixed)">#2618</a>. </p> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/54373" title="Fix doc generation for array reference parameters. ">r54373</a> | chris_kohlhoff | 2009-06-26 21:03:14 +1000 (Fri, 26 Jun 2009) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> Fix doc generation for array reference parameters. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/54376" title="Fix bug in hash resize. Ref #3095. ">r54376</a> | chris_kohlhoff | 2009-06-26 23:35:04 +1000 (Fri, 26 Jun 2009) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> Fix bug in hash resize. Ref <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3095" title="#3095: Bugs: bug in automatic resizing of the bucket array (closed: fixed)">#3095</a>. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/54377" title="Remove a local variable that was hiding the ec parameter and ...">r54377</a> | chris_kohlhoff | 2009-06-26 23:55:24 +1000 (Fri, 26 Jun 2009) | 3 lines </p> </blockquote> <p> </p> <blockquote> <p> Remove a local variable that was hiding the ec parameter and preventing error codes from being correctly propagated. Ref <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3216" title="#3216: Bugs: variable shadowing with possibly bad implications (closed: fixed)">#3216</a>. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/54390" title="Fix failures reported when the tests are built with _GLIBCXX_DEBUG. ...">r54390</a> | chris_kohlhoff | 2009-06-27 12:17:49 +1000 (Sat, 27 Jun 2009) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> Fix failures reported when the tests are built with _GLIBCXX_DEBUG. Ref <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3098" title="#3098: Bugs: Abort in boost::asio::ip::tcp::acceptor constructor on Mac OS X (closed: fixed)">#3098</a>. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/54392" title="Fix custom memory allocation for timers. Ref #3107. ">r54392</a> | chris_kohlhoff | 2009-06-27 15:24:16 +1000 (Sat, 27 Jun 2009) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> Fix custom memory allocation for timers. Ref <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3107" title="#3107: Bugs: Error in allocation/dealocation of timers (closed: fixed)">#3107</a>. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/54393" title="Fix various g++ warnings. Ref #1341. ">r54393</a> | chris_kohlhoff | 2009-06-27 17:07:40 +1000 (Sat, 27 Jun 2009) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> Fix various g++ warnings. Ref <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/1341" title="#1341: Patches: unused argument and another g++ warning (closed: fixed)">#1341</a>. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/54400" title="Use boost::throw_exception() rather than throw keyword to allow asio ...">r54400</a> | chris_kohlhoff | 2009-06-27 17:52:11 +1000 (Sat, 27 Jun 2009) | 4 lines </p> </blockquote> <p> </p> <blockquote> <p> Use boost::throw_exception() rather than throw keyword to allow asio to be used when exception support is disabled. Note that the SSL wrappers still require exception support. Refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2754" title="#2754: Patches: [PATCH] building asio without exception support (closed: fixed)">#2754</a>. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/54407" title="Make links to function overloads more obvious. ">r54407</a> | chris_kohlhoff | 2009-06-27 19:13:24 +1000 (Sat, 27 Jun 2009) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> Make links to function overloads more obvious. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/54466" title="Add header file information to reference docs. Refs #3157. ">r54466</a> | chris_kohlhoff | 2009-06-28 23:07:43 +1000 (Sun, 28 Jun 2009) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> Add header file information to reference docs. Refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3157" title="#3157: Support Requests: ASIO Reference has no header file information (closed: fixed)">#3157</a>. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/54467" title="Treat 0-byte reads and writes as no-ops to comply with the documented ...">r54467</a> | chris_kohlhoff | 2009-06-28 23:20:17 +1000 (Sun, 28 Jun 2009) | 4 lines </p> </blockquote> <p> </p> <blockquote> <p> Treat 0-byte reads and writes as no-ops to comply with the documented type requirements for <a class="missing wiki">SyncReadStream</a>, <a class="missing wiki">AsyncReadStream</a>, <a class="missing wiki">SyncWriteStream</a> and <a class="missing wiki">AsyncWriteStream</a>. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/54498" title="Add enum values to doc index. Refs #2620. ">r54498</a> | chris_kohlhoff | 2009-06-29 19:32:41 +1000 (Mon, 29 Jun 2009) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> Add enum values to doc index. Refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2620" title="#2620: Bugs: Missing entries in documentation index (closed: fixed)">#2620</a>. </p> </blockquote> <p> ........ </p> Ticket