#7242 closed Bugs (fixed)
GCC 4.8 warns unused local typedef
| Reported by: | Owned by: | John Maddock | |
|---|---|---|---|
| Milestone: | To Be Determined | Component: | static_assert |
| Version: | Boost Release Branch | Severity: | Problem |
| Keywords: | Cc: |
Description
GCC 4.8 warns unused local typedef. see followings.
$ cat hoge.cpp
#include <boost/static_assert.hpp>
int main()
{
BOOST_STATIC_ASSERT(true);
}
$ g++-4.8.0 -Wall -Iboost-trunk hoge.cpp
In file included from boost-trunk/boost/config.hpp:57:0,
from boost-trunk/boost/static_assert.hpp:17,
from hoge.cpp:1:
hoge.cpp: In function 'int main()':
boost-trunk/boost/static_assert.hpp:125:21: warning: typedef 'boost_static_assert_typedef_5' locally defined but not used [-Wunused-local-typedefs]
BOOST_JOIN(boost_static_assert_typedef_, __LINE__)
^
hoge.cpp:5:5: note: in expansion of macro 'BOOST_STATIC_ASSERT'
BOOST_STATIC_ASSERT(true);
^
To suppress this warnings, append __attribute__((unused)).
Change History (7)
comment:1 by , 10 years ago
comment:2 by , 10 years ago
I tried followings, and it works for me.
#include <boot/static_assert.hpp>
int main()
{
BOOST_STATIC_ASSERT(true) __attribute__((unused));
}
However, in some cases seems doesn't work and I think it's GCC defect. I'll try to narrow down the cause and report it to GCC bugzilla.
comment:3 by , 10 years ago
The GCC defects fixed in trunk; http://gcc.gnu.org/PR54372 . The solution works well, now.
comment:4 by , 10 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
comment:7 by , 7 years ago
I see the same warning with clang-3.6.1.
The GCC syntax:
__attribute__((unused))
is accepted by clang, at least since clang-3.4. I suggest to adapt the following lines, of boost/static_assert.hpp so that clang>=3.4 is also taken into account:
#if defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7))) # define BOOST_STATIC_ASSERT_UNUSED_ATTRIBUTE __attribute__((unused)) #else # define BOOST_STATIC_ASSERT_UNUSED_ATTRIBUTE #endif
Should I open a new ticket?

Have you actually tried to use
__attribute__((unused))to suppress these warnings? I can not make it work.