Boost C++ Libraries: Ticket #8743: warning in BOOST_BIMAP_STATIC_ERROR with clang trunk https://svn.boost.org/trac10/ticket/8743 <p> The following code: </p> <pre class="wiki">#include &lt;boost/bimap/detail/debug/static_error.hpp&gt; template &lt;typename T&gt; struct S { BOOST_BIMAP_STATIC_ERROR(SOME_MESSAGE, (T)); }; </pre><p> produces a warning with clang trunk: </p> <pre class="wiki">test.cpp:6:5: warning: class member cannot be redeclared [-Wgnu] BOOST_BIMAP_STATIC_ERROR(SOME_MESSAGE, (T)); ^ boost/bimap/detail/debug/static_error.hpp:30:30: note: expanded from macro 'BOOST_BIMAP_STATIC_ERROR' BOOST_PP_CAT(BIMAP_STATIC_ERROR__,MESSAGE), \ ^ boost/preprocessor/cat.hpp:22:32: note: expanded from macro 'BOOST_PP_CAT' # define BOOST_PP_CAT(a, b) BOOST_PP_CAT_I(a, b) ^ boost/preprocessor/cat.hpp:29:34: note: expanded from macro 'BOOST_PP_CAT_I' # define BOOST_PP_CAT_I(a, b) a ## b ^ &lt;scratch space&gt;:167:1: note: expanded from here BIMAP_STATIC_ERROR__SOME_MESSAGE ^ boost/mpl/assert.hpp:435:59: note: expanded from macro 'BOOST_MPL_ASSERT_MSG' BOOST_MPL_ASSERT_MSG_IMPL( BOOST_MPL_AUX_PP_COUNTER(), c, msg, types_ ) \ ^ boost/mpl/assert.hpp:419:8: note: expanded from macro '\ BOOST_MPL_ASSERT_MSG_IMPL' struct msg; \ ^ test.cpp:6:5: note: previous declaration is here boost/bimap/detail/debug/static_error.hpp:28:16: note: expanded from macro 'BOOST_BIMAP_STATIC_ERROR' struct BOOST_PP_CAT(BIMAP_STATIC_ERROR__,MESSAGE) {}; \ ^ boost/preprocessor/cat.hpp:22:32: note: expanded from macro 'BOOST_PP_CAT' # define BOOST_PP_CAT(a, b) BOOST_PP_CAT_I(a, b) ^ boost/preprocessor/cat.hpp:29:34: note: expanded from macro 'BOOST_PP_CAT_I' # define BOOST_PP_CAT_I(a, b) a ## b ^ &lt;scratch space&gt;:166:1: note: expanded from here BIMAP_STATIC_ERROR__SOME_MESSAGE ^ </pre><p> The reason is that the macro expands to the following: </p> <pre class="wiki">template &lt;typename T&gt; struct S { struct BIMAP_STATIC_ERROR__SOME_MESSAGE {}; struct BIMAP_STATIC_ERROR__SOME_MESSAGE; // &lt;snip rest of expansion&gt; }; </pre><p> The nested structure 'BIMAP_STATIC_ERROR_SOME_MESSAGE' is defined, and then redeclared. Such redeclaration is, apparently, not allowed. GCC accepts it as an extension, but the trunk version of clang warns about it. </p> <p> As a result, any code that uses Bimap is littered with warnings of this sort (since the library uses BOOST_BIMAP_STATIC_ERROR in multiple places). </p> <p> The fix is simple: modify BOOST_BIMAP_STATIC_ERROR to omit the definition, which is not necessary. The declaration emitted by BOOST_MPL_ASSERT_MSG is sufficient. </p> <p> Patch attached. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8743 Trac 1.4.3 Nathan Ridge Fri, 28 Jun 2013 08:12:52 GMT attachment set https://svn.boost.org/trac10/ticket/8743 https://svn.boost.org/trac10/ticket/8743 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">bimap-warning.patch</span> </li> </ul> <p> patch that fixes the warning </p> Ticket Braden McDaniel <braden@…> Tue, 11 Mar 2014 14:22:39 GMT version changed; cc set https://svn.boost.org/trac10/ticket/8743#comment:1 https://svn.boost.org/trac10/ticket/8743#comment:1 <ul> <li><strong>cc</strong> <span class="trac-author">braden@…</span> added </li> <li><strong>version</strong> <span class="trac-field-old">Boost Development Trunk</span> → <span class="trac-field-new">Boost 1.55.0</span> </li> </ul> Ticket Jim King <jim.king@…> Fri, 09 May 2014 21:39:51 GMT <link>https://svn.boost.org/trac10/ticket/8743#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8743#comment:2</guid> <description> <p> I also ran into this with the boost "master" tip for 1.56 plus the latest clang-3.5.0. If you use -Wall -Werror in your projects this becomes a build error. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Wed, 14 May 2014 14:27:52 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8743#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8743#comment:3</guid> <description> <p> doesn't clear the issue.. created a lot of warnings and issues </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Nathan Ridge</dc:creator> <pubDate>Wed, 14 May 2014 14:46:37 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8743#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8743#comment:4</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/8743#comment:3" title="Comment 3">anonymous</a>: </p> <blockquote class="citation"> <p> doesn't clear the issue.. created a lot of warnings and issues </p> </blockquote> <p> Are you referring to my patch from comment 1? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Wed, 08 Oct 2014 00:45:05 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8743#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8743#comment:5</guid> <description> <p> This patch fixes using bimap on clang with option <code>-Wall -Werror</code> perfectly; should be applied to upstream. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Thu, 16 Apr 2015 00:10:10 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8743#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8743#comment:6</guid> <description> <p> Why hasn't this patch been merged yet? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Finomnis</dc:creator> <pubDate>Fri, 29 May 2015 14:28:55 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8743#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8743#comment:7</guid> <description> <p> +1, fixed my problems as well. Could one of the developers at least give some kind of a statement why this didn't get merged yet? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Sun, 14 Jun 2015 21:32:33 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8743#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8743#comment:8</guid> <description> <p> +1, fixed my problem as well. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Matias Capeletto</dc:creator> <pubDate>Fri, 26 Feb 2016 09:56:43 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/8743#comment:9 https://svn.boost.org/trac10/ticket/8743#comment:9 <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> Applied from pull-request: <a class="ext-link" href="https://github.com/boostorg/bimap/commit/e4b46b3258f0a5be1484d9c507f6133930498925"><span class="icon">​</span>https://github.com/boostorg/bimap/commit/e4b46b3258f0a5be1484d9c507f6133930498925</a>, thanks and sorry for the delay. </p> Ticket