Opened 11 years ago

Closed 9 years ago

#6136 closed Patches (fixed)

Fix for "variable set but not used" warning with GCC >= 4.6

Reported by: zeratul976@… Owned by: az_sw_dude
Milestone: To Be Determined Component: date_time
Version: Boost 1.54.0 Severity: Problem
Keywords: Cc:

Description

GCC >= 4.6 gives the following "variable set but not used" warnings for code in boost/date_time/format_date_parser.hpp:

../../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]

The warnings are triggered by any code that instantiates the format_date_parser class, for example:

#include <sstream>
#include <boost/date_time/posix_time/posix_time.hpp>

int main()
{
    std::stringstream ss;
    boost::posix_time::ptime p;
    ss >> p;
}

Looking at the code, I can see that the 'current_char' variable is indeed set but never used in those functions.

The attached patch fixes the warnings by removing the 'current_char' variable from those functions.

Attachments (1)

gcc-warnings.patch (3.9 KB ) - added by zeratul976@… 11 years ago.
patch that fixes the warnings

Download all attachments as: .zip

Change History (8)

by zeratul976@…, 11 years ago

Attachment: gcc-warnings.patch added

patch that fixes the warnings

comment:1 by Marshall Clow, 10 years ago

(In [80699]) Remove unused variable; Refs #7342 Refs #6136

comment:2 by Marshall Clow, 10 years ago

Resolution: fixed
Status: newclosed

(In [80797]) Merge bug fixes to release; Fixes #5550 Fixes #6136 Fixes #6513 Fixes #7111 Fixes #7112 Fixes #7113 Fixes #7342 Fixes #7426

comment:3 by Johan Lundberg <lundberj@…>, 9 years ago

Resolution: fixed
Status: closedreopened

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?

Example of what I expected was the removal of the unused variable current_char:

https://svn.boost.org/trac/boost/changeset/80797#file5

but what is found in 1.54 beta1 looks like this

http://svn.boost.org/svn/boost/trunk/boost/date_time/format_date_parser.hpp

in reply to:  3 comment:4 by Johan Lundberg <lundberj@…>, 9 years ago

Version: Boost 1.48.0Boost 1.54.0

To clarify (also selecting 1.54.0 as Version) that the issue is still found in

  • 1.54 beta1
  • trunk
  • release branch

http://svn.boost.org/svn/boost/branches/release/boost/date_time/format_date_parser.hpp http://svn.boost.org/svn/boost/trunk/boost/date_time/format_date_parser.hpp

comment:5 by Marshall Clow, 9 years ago

I have no explanation for this.

I made these changes; see [80699] (trunk) and [80797] (release), but the files in SVN no longer contain those changes.

comment:6 by Marshall Clow, 9 years ago

(In [84834]) Fixed more compiler warnings; Refs #6136

comment:7 by Marshall Clow, 9 years ago

Resolution: fixed
Status: reopenedclosed

(In [84860]) Merge bug fixes to release. Fixes #6136. Fixes #5550

Note: See TracTickets for help on using tickets.