Opened 6 years ago

Last modified 5 years ago

#7434 new Bugs

Lock used in flyweight causes erroneous "unused variable" warning when compiling with clang

Reported by: Pierre Imai <pierre.imai@…> Owned by: Joaquín M López Muñoz
Milestone: To Be Determined Component: flyweight
Version: Boost 1.51.0 Severity: Problem
Keywords: clang unused variable warning Cc:

Description

The lock functionality in boost/flyweight/detail/flyweight_core.hpp causes the following warning when compiled with "Apple clang version 4.0 (tags/Apple/clang-421.0.60) (based on LLVM 3.1svn)" with option "-Wunused-variable":

In file included from /opt/local/include/boost/flyweight/flyweight.hpp:22:
/opt/local/include/boost/flyweight/detail/flyweight_core.hpp:189:22: error: unused variable 'lock' [-Werror,-Wunused-variable]
    lock_type        lock(mutex());

This problem can be fixed by adding the following code to the file, before / after the corresponding blocks for MSVC

#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
#ifdef __clang__
#pragma clang diagnostic pop
#endif

Change History (1)

comment:1 Changed 5 years ago by Joaquín M López Muñoz

Hi Pierre,

Can you provide me with two bits of additional info?

  • Can you check the values of clang_major and clang_minor? I'd like make the patch using BOOST_WORKAROUND and BOOST_TESTED_AT so as to record the specific version of Clang where this is happening.
  • Do you have access to GCC in your environment? Does the equivalent warning happen?

Thank you,

Note: See TracTickets for help on using tickets.