Opened 9 years ago

Closed 5 years ago

#8546 closed Bugs (fixed)

GCC 4.8 warns unused local typedef

Reported by: Wei-Chiu Chuang <weichiu@…> Owned by: Marshall Clow
Milestone: To Be Determined Component: gil USE GITHUB
Version: Boost Development Trunk Severity: Problem
Keywords: Cc: mateusz@…

Description

This is a similar issue to Ticket #7242, except this affects more than one component in addition to static_assert: gcc 4.8.0 warns unused local typedefs with -Wall option added and it pertains to boost/concept/detail/general.hpp, boost/lexical_cast.hpp, boost/algorithm/string/detail/finder.hpp

In file included from /scratch/chuangw/boost/boost-trunk/boost/mpl/aux_/integral_wrapper.hpp:22:0,
                 from /scratch/chuangw/boost/boost-trunk/boost/mpl/int.hpp:20,
                 from /scratch/chuangw/boost/boost-trunk/boost/mpl/lambda_fwd.hpp:23,
                 from /scratch/chuangw/boost/boost-trunk/boost/mpl/aux_/na_spec.hpp:18,
                 from /scratch/chuangw/boost/boost-trunk/boost/mpl/if.hpp:19,
                 from /scratch/chuangw/boost/boost-trunk/boost/lexical_cast.hpp:37,
                 from /scratch/chuangw/nightlybuild/mace-fullcontext/lib/Serializable.h:45,
                 from /scratch/chuangw/nightlybuild/mace-fullcontext/lib/CollectionSerializers.h:34,
                 from /scratch/chuangw/nightlybuild/mace-fullcontext/lib/mhash_map.h:57,
                 from /scratch/chuangw/nightlybuild/mace-fullcontext/lib/Accumulator.h:36,
                 from /scratch/chuangw/nightlybuild/mace-fullcontext/lib/Scheduler.cc:31:
/scratch/chuangw/boost/boost-trunk/boost/concept_check.hpp: In function 'void boost::function_requires(Model*)':
/scratch/chuangw/boost/boost-trunk/boost/concept/detail/general.hpp:71:20: error: typedef 'boost_concept_check51' locally defined but not used [-Werror=unused-local-typedefs]
       BOOST_PP_CAT(boost_concept_check,__LINE__)
                    ^
/scratch/chuangw/boost/boost-trunk/boost/preprocessor/cat.hpp:29:34: note: in definition of macro 'BOOST_PP_CAT_I'
 #    define BOOST_PP_CAT_I(a, b) a ## b
                                  ^
/scratch/chuangw/boost/boost-trunk/boost/concept/detail/general.hpp:71:7: note: in expansion of macro 'BOOST_PP_CAT'
       BOOST_PP_CAT(boost_concept_check,__LINE__)
       ^
/scratch/chuangw/boost/boost-trunk/boost/concept/assert.hpp:44:5: note: in expansion of macro 'BOOST_CONCEPT_ASSERT_FN'
     BOOST_CONCEPT_ASSERT_FN(void(*)ModelInParens)
     ^
/scratch/chuangw/boost/boost-trunk/boost/concept_check.hpp:51:7: note: in expansion of macro 'BOOST_CONCEPT_ASSERT'
       BOOST_CONCEPT_ASSERT((Model));
       ^

Suggested fix: add

__attribute__((unused))

if gcc version is >= 4.8.0

Attachments (2)

diff1 (3.8 KB ) - added by Wei-Chiu Chuang <weichiu@…> 9 years ago.
patch boost/concept/detail/general.hpp, boost/lexical_cast.hpp and boost/algorithm/string/detail/finder.hpp to eliminate unused local typedefs warning
algorithm.patch (1.8 KB ) - added by Chris Stylianou <chris5287@…> 9 years ago.

Download all attachments as: .zip

Change History (16)

by Wei-Chiu Chuang <weichiu@…>, 9 years ago

Attachment: diff1 added

patch boost/concept/detail/general.hpp, boost/lexical_cast.hpp and boost/algorithm/string/detail/finder.hpp to eliminate unused local typedefs warning

comment:1 by viboes, 9 years ago

Hi I'm suffering from the same warnings using other libraries.

Shouldn't this be included on boost/config/suffix.hpp

#if defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)))
#  define BOOST_ATTRIBUTE_UNUSED __attribute__((unused))
#else
#  define BOOST_ATTRIBUTE_UNUSED
#endif

See #8549.

comment:2 by viboes, 9 years ago

[84470] is related to this. Could this be closed?

comment:3 by Chris Stylianou <chris5287@…>, 9 years ago

Component: concept_checkalgorithm
Owner: changed from jsiek to Marshall Clow
Type: PatchesBugs
Version: Boost Development TrunkBoost 1.54.0

It appears 'boost/concept/detail/general.hpp' and 'boost/lexical_cast.hpp' have already been patched in the trunk.

I've recreated the patch to target the 'boost/algorithm/string/detail/finder.hpp' warnings:

finder.hpp:145
typedef ‘input_iterator_type’ locally defined but not used [-Wunused-local-typedefs]
finder.hpp:266
typedef ‘input_iterator_type’ locally defined but not used [-Wunused-local-typedefs]
finder.hpp:301
typedef ‘input_iterator_type’ locally defined but not used [-Wunused-local-typedefs]
finder.hpp:365
typedef ‘input_iterator_type’ locally defined but not used [-Wunused-local-typedefs]
finder.hpp:439
typedef ‘input_iterator_type’ locally defined but not used [-Wunused-local-typedefs]

by Chris Stylianou <chris5287@…>, 9 years ago

Attachment: algorithm.patch added

comment:4 by Marshall Clow, 9 years ago

(In [85106]) Removed unused typedef; Refs #8546

comment:5 by Marshall Clow, 9 years ago

Resolution: fixed
Status: newclosed

(In [85134]) Merge bug fix to Release; Fixes #8546

comment:6 by roland@…, 9 years ago

It appears [84470] was not merged to any release (yet) -- it is not present in 1.55.0 and with that release, I get errors like the following with gcc 4.8 and -Wall -Werror:

include/boost/concept_check.hpp: In function ‘void boost::function_requires(Model*)’:
include/boost/concept_check.hpp:45:113: error: typedef ‘boost_concept_check45’ locally defined but not used [-Werror=unused-local-typedefs]
       BOOST_CONCEPT_ASSERT((Model));

so I think this bug may have been closed slightly prematurely.

comment:7 by John Maddock, 9 years ago

This has just recently been merged to release in Git.

comment:8 by anonymous, 9 years ago

Component: algorithmGIL
Resolution: fixed
Status: closedreopened
Version: Boost 1.54.0Boost Development Trunk

This applies to the new GIL currently in trunk.

comment:9 by gereon.kremer@…, 7 years ago

This behaviour still persists as of now (boost 1.58.0, clang 3.6.2). Have the above patches not made it, or is there another issue?

comment:10 by Marshall Clow, 7 years ago

This behaviour still persists as of now (boost 1.58.0, clang 3.6.2).

I will admit to having trouble following this bug's history. It started out in Boost.Algorithm, moved into Boost.Concept, (and now GIL?) and I don't really know what you are referring to when you say "this behavior still persists".

The patch for Boost.Algorithm appeared in a release a long time ago, and the patch for Boost.Concept appears to be part of the 1.59 release.

If you're having other problems, let me know - but please be specific.

comment:11 by gereon.kremer@…, 7 years ago

Okay, then I'll wait for 1.59 and see if it vanishes. As of 1.58 (with clang 3.6.2 and -Wall) and the following input, I still get this "unused typedef" warning:

#include <boost/concept_check.hpp>
template<typename T, typename TT>
void require_type(const TT& tt) {
    T t = tt;
    (void)(t);
}
template<typename T1>
struct UnaryMinus {
    T1 t;
    BOOST_CONCEPT_USAGE(UnaryMinus) { require_type<T1>(-t); }
};
int main() {
    BOOST_CONCEPT_ASSERT((UnaryMinus<int>));
}

comment:12 by Marshall Clow, 7 years ago

Okay, then I'll wait for 1.59 and see if it vanishes

Boost 1.59.0 was released three weeks ago. :-)

Using that, I get no warning with your code and clang ToT or GCC 5.1

comment:13 by Mateusz Loskot, 6 years ago

Cc: mateusz@… added

comment:14 by Marshall Clow, 5 years ago

Resolution: fixed
Status: reopenedclosed

I get no warnings (with Boost 1.64.0), so I'm closing this as fixed.

Note: See TracTickets for help on using tickets.