Boost C++ Libraries: Ticket #7242: GCC 4.8 warns unused local typedef https://svn.boost.org/trac10/ticket/7242 <p> GCC 4.8 warns unused local typedef. see followings. </p> <pre class="wiki">$ cat hoge.cpp #include &lt;boost/static_assert.hpp&gt; 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); ^ </pre><p> To suppress this warnings, append __attribute__((unused)). </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7242 Trac 1.4.3 larsbj@… Fri, 24 Aug 2012 22:40:05 GMT <link>https://svn.boost.org/trac10/ticket/7242#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7242#comment:1</guid> <description> <p> Have you actually tried to use <code>__attribute__((unused))</code> to suppress these warnings? I can not make it work. </p> </description> <category>Ticket</category> </item> <item> <author>Kohei Takahashi <flast@…></author> <pubDate>Sat, 25 Aug 2012 05:17:57 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7242#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7242#comment:2</guid> <description> <p> I tried followings, and it works for me. </p> <pre class="wiki">#include &lt;boot/static_assert.hpp&gt; int main() { BOOST_STATIC_ASSERT(true) __attribute__((unused)); } </pre><p> 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. </p> </description> <category>Ticket</category> </item> <item> <author>Kohei Takahashi <flast@…></author> <pubDate>Sat, 29 Sep 2012 01:16:22 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7242#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7242#comment:3</guid> <description> <p> The GCC defects fixed in trunk; <a class="ext-link" href="http://gcc.gnu.org/PR54372"><span class="icon">​</span>http://gcc.gnu.org/PR54372</a> . The solution works well, now. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Thu, 14 Feb 2013 18:31:35 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/7242#comment:4 https://svn.boost.org/trac10/ticket/7242#comment:4 <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/82886" title="Use variadic macros in static assert to make use easier. Add warning ...">[82886]</a>) Use variadic macros in static assert to make use easier. Add warning suppression for GCC. Minor doc fix. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/5810" title="#5810: Bugs: BOOST_STATIC_ASSERT requires unnecessary parentheses (closed: fixed)">#5810</a>. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7242" title="#7242: Bugs: GCC 4.8 warns unused local typedef (closed: fixed)">#7242</a>. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7966" title="#7966: Bugs: static_assert: doc: nitpicking (closed: fixed)">#7966</a>. </p> Ticket laurent.rineau__boost_trac@… Thu, 14 Mar 2013 13:32:32 GMT <link>https://svn.boost.org/trac10/ticket/7242#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7242#comment:5</guid> <description> <p> Will that patch be included in version 1.54? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Tue, 19 Mar 2013 18:10:31 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7242#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7242#comment:6</guid> <description> <p> Should be yes. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Wed, 15 Jul 2015 09:08:21 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7242#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7242#comment:7</guid> <description> <p> I see the same warning with clang-3.6.1. </p> <p> The GCC syntax: </p> <pre class="wiki">__attribute__((unused)) </pre><p> is accepted by clang, <a class="ext-link" href="http://llvm.org/releases/3.4/tools/clang/docs/LanguageExtensions.html#non-standard-c-11-attributes"><span class="icon">​</span>at least since clang-3.4</a>. I suggest to adapt the following lines, of boost/static_assert.hpp so that clang&gt;=3.4 is also taken into account: </p> <div class="wiki-code"><div class="code"><pre><span class="cp">#if defined(__GNUC__) &amp;&amp; ((__GNUC__ &gt; 4) || ((__GNUC__ == 4) &amp;&amp; (__GNUC_MINOR__ &gt;= 7)))</span> <span class="cp"># define BOOST_STATIC_ASSERT_UNUSED_ATTRIBUTE __attribute__((unused))</span> <span class="cp">#else</span> <span class="cp"># define BOOST_STATIC_ASSERT_UNUSED_ATTRIBUTE</span> <span class="cp">#endif</span> </pre></div></div><p> Should I open a new ticket? </p> </description> <category>Ticket</category> </item> </channel> </rss>