Boost C++ Libraries: Ticket #6136: Fix for "variable set but not used" warning with GCC >= 4.6 https://svn.boost.org/trac10/ticket/6136 <p> GCC &gt;= 4.6 gives the following "variable set but not used" warnings for code in boost/date_time/format_date_parser.hpp: </p> <pre class="wiki">../../lib/boost/boost/date_time/format_date_parser.hpp:479:11: warning: variable 'current_char' set but not used [-Wunused-but-set-variable] ../../lib/boost/boost/date_time/format_date_parser.hpp:584:11: warning: variable 'current_char' set but not used [-Wunused-but-set-variable] ../../lib/boost/boost/date_time/format_date_parser.hpp:677:11: warning: variable 'current_char' set but not used [-Wunused-but-set-variable] </pre><p> The warnings are triggered by any code that instantiates the format_date_parser class, for example: </p> <pre class="wiki">#include &lt;sstream&gt; #include &lt;boost/date_time/posix_time/posix_time.hpp&gt; int main() { std::stringstream ss; boost::posix_time::ptime p; ss &gt;&gt; p; } </pre><p> Looking at the code, I can see that the 'current_char' variable is indeed set but never used in those functions. </p> <p> The attached patch fixes the warnings by removing the 'current_char' variable from those functions. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6136 Trac 1.4.3 zeratul976@… Thu, 17 Nov 2011 22:03:14 GMT attachment set https://svn.boost.org/trac10/ticket/6136 https://svn.boost.org/trac10/ticket/6136 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">gcc-warnings.patch</span> </li> </ul> <p> patch that fixes the warnings </p> Ticket Marshall Clow Mon, 24 Sep 2012 21:41:08 GMT <link>https://svn.boost.org/trac10/ticket/6136#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6136#comment:1</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/80699" title="Remove unused variable; Refs #7342 Refs #6136">[80699]</a>) Remove unused variable; Refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7342" title="#7342: Bugs: Warning in format_date_parser.hpp (closed: fixed)">#7342</a> Refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6136" title="#6136: Patches: Fix for &#34;variable set but not used&#34; warning with GCC &gt;= 4.6 (closed: fixed)">#6136</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Marshall Clow</dc:creator> <pubDate>Sun, 30 Sep 2012 23:25:27 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/6136#comment:2 https://svn.boost.org/trac10/ticket/6136#comment:2 <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">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/80797" title="Merge bug fixes to release; Fixes #5550 Fixes #6136 Fixes #6513 Fixes ...">[80797]</a>) Merge bug fixes to release; Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/5550" title="#5550: Bugs: Missing initializer warning in date_time/date_facet.hpp (closed: fixed)">#5550</a> Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6136" title="#6136: Patches: Fix for &#34;variable set but not used&#34; warning with GCC &gt;= 4.6 (closed: fixed)">#6136</a> Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6513" title="#6513: Bugs: assignment vs comparison in unit test (closed: fixed)">#6513</a> Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7111" title="#7111: Feature Requests: Switch case's default missing in date_time (closed: fixed)">#7111</a> Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7112" title="#7112: Feature Requests: Switch case default missing in date_time (closed: fixed)">#7112</a> Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7113" title="#7113: Feature Requests: In date_time default case of switch is missing. (closed: fixed)">#7113</a> Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7342" title="#7342: Bugs: Warning in format_date_parser.hpp (closed: fixed)">#7342</a> Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7426" title="#7426: Patches: Warning fixes in datetime (closed: fixed)">#7426</a> </p> Ticket Johan Lundberg <lundberj@…> Wed, 19 Jun 2013 11:16:16 GMT status changed; resolution deleted https://svn.boost.org/trac10/ticket/6136#comment:3 https://svn.boost.org/trac10/ticket/6136#comment:3 <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> I would like to bring attention to this bug. I'm surprised that although it was fixed nine months ago, the change did not make it to 1.54 beta1 or to trunk. Is that an oversight? </p> <p> Example of what I expected was the removal of the unused variable current_char: </p> <p> <a class="ext-link" href="https://svn.boost.org/trac/boost/changeset/80797#file5"><span class="icon">​</span>https://svn.boost.org/trac/boost/changeset/80797#file5</a> </p> <p> but what is found in 1.54 beta1 looks like this </p> <p> <a class="ext-link" href="http://svn.boost.org/svn/boost/trunk/boost/date_time/format_date_parser.hpp"><span class="icon">​</span>http://svn.boost.org/svn/boost/trunk/boost/date_time/format_date_parser.hpp</a> </p> Ticket Johan Lundberg <lundberj@…> Wed, 19 Jun 2013 11:25:05 GMT version changed https://svn.boost.org/trac10/ticket/6136#comment:4 https://svn.boost.org/trac10/ticket/6136#comment:4 <ul> <li><strong>version</strong> <span class="trac-field-old">Boost 1.48.0</span> → <span class="trac-field-new">Boost 1.54.0</span> </li> </ul> <p> To clarify (also selecting 1.54.0 as Version) that the issue is still found in </p> <ul><li>1.54 beta1 </li><li>trunk </li><li>release branch </li></ul><p> <a class="ext-link" href="http://svn.boost.org/svn/boost/branches/release/boost/date_time/format_date_parser.hpp"><span class="icon">​</span>http://svn.boost.org/svn/boost/branches/release/boost/date_time/format_date_parser.hpp</a> <a class="ext-link" href="http://svn.boost.org/svn/boost/trunk/boost/date_time/format_date_parser.hpp"><span class="icon">​</span>http://svn.boost.org/svn/boost/trunk/boost/date_time/format_date_parser.hpp</a> </p> Ticket Marshall Clow Wed, 19 Jun 2013 13:32:37 GMT <link>https://svn.boost.org/trac10/ticket/6136#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6136#comment:5</guid> <description> <p> I have no explanation for this. </p> <p> I made these changes; see <a class="changeset" href="https://svn.boost.org/trac10/changeset/80699" title="Remove unused variable; Refs #7342 Refs #6136">[80699]</a> (trunk) and <a class="changeset" href="https://svn.boost.org/trac10/changeset/80797" title="Merge bug fixes to release; Fixes #5550 Fixes #6136 Fixes #6513 Fixes ...">[80797]</a> (release), but the files in SVN no longer contain those changes. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Marshall Clow</dc:creator> <pubDate>Wed, 19 Jun 2013 15:25:06 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6136#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6136#comment:6</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/84834" title="Fixed more compiler warnings; Refs #6136">[84834]</a>) Fixed more compiler warnings; Refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6136" title="#6136: Patches: Fix for &#34;variable set but not used&#34; warning with GCC &gt;= 4.6 (closed: fixed)">#6136</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Marshall Clow</dc:creator> <pubDate>Fri, 21 Jun 2013 15:04:14 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/6136#comment:7 https://svn.boost.org/trac10/ticket/6136#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> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/84860" title="Merge bug fixes to release. Fixes #6136. Fixes #5550">[84860]</a>) Merge bug fixes to release. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6136" title="#6136: Patches: Fix for &#34;variable set but not used&#34; warning with GCC &gt;= 4.6 (closed: fixed)">#6136</a>. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/5550" title="#5550: Bugs: Missing initializer warning in date_time/date_facet.hpp (closed: fixed)">#5550</a> </p> Ticket