Boost C++ Libraries: Ticket #5522: [foreach] Warning with gcc-4.6.0 and -Wconversion https://svn.boost.org/trac10/ticket/5522 <p> gcc-4.6.0 made Boost.foreach unusable in 1.46.1 because the rvalue detection no longer works. Now, there is a fix in trunk for it but it has a nasty side effect, namely a warning that is emitted whenever foreach is used with an rvalue and -Wconversion is turned on. Sadly, this warning cannot be ignored by including Boost with -isystem because the code is generated by a macro, obviously. </p> <p> I would be glad if this could be fixed somehow because -Wconversion is a crucial warning option to me. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5522 Trac 1.4.3 sefi@… Thu, 05 May 2011 15:29:53 GMT attachment set https://svn.boost.org/trac10/ticket/5522 https://svn.boost.org/trac10/ticket/5522 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">test.cpp</span> </li> </ul> <p> Testcase </p> Ticket sefi@… Thu, 05 May 2011 15:30:58 GMT attachment set https://svn.boost.org/trac10/ticket/5522 https://svn.boost.org/trac10/ticket/5522 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">output.log</span> </li> </ul> <p> Warning output </p> Ticket anonymous Mon, 23 May 2011 08:42:14 GMT <link>https://svn.boost.org/trac10/ticket/5522#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5522#comment:1</guid> <description> <p> See also: <a class="ext-link" href="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49021#c12"><span class="icon">​</span>http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49021#c12</a>, where a related problem is discussed, the final resolution is pointing to a bug in BOOST_FOREACH_COMPILE_TIME_CONST_RVALUE_DETECTION. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Eric Niebler</dc:creator> <pubDate>Sun, 29 May 2011 15:35:25 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/5522#comment:2 https://svn.boost.org/trac10/ticket/5522#comment:2 <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">wontfix</span> </li> </ul> <p> I believe gcc is warning about perfectly valid code. There is no other way to detect const rvalues in C++98 that I'm aware of. I don't know how to fix this, and using <code>_Pragma</code> to suppress the warning didn't work. I'm sorry, I don't think this is fixable. </p> <p> If you come up with a patch, please reopen this ticket. Thanks. </p> Ticket anonymous Tue, 18 Feb 2014 20:39:43 GMT <link>https://svn.boost.org/trac10/ticket/5522#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5522#comment:3</guid> <description> <p> For what it's worth, I found a workaround this way. I'm assuming the compiler will optimize out the v<span class="underline">LINE</span> variables. The <span class="underline">LINE</span> concatenation is required if you have multiple FOREACH calls with\in the same scope. </p> <pre class="wiki">#if defined(__GNUC__) #define M_FOREACH(elem, vec) M_FOREACH_W_LINE(elem,vec,__LINE__) #define M_FOREACH_W_LINE(elem, vec, n) M_FOREACH_CONCAT_VAR(elem, vec, n) #define M_FOREACH_CONCAT_VAR(elem, vec, n) \ __typeof__(vec) v ## n = vec; \ BOOST_FOREACH(elem, v ## n) #else #define M_FOREACH(elem, vec) \ BOOST_FOREACH(elem, vec) #endif </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Tue, 18 Feb 2014 20:42:35 GMT</pubDate> <title>status, type changed; resolution deleted https://svn.boost.org/trac10/ticket/5522#comment:4 https://svn.boost.org/trac10/ticket/5522#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>type</strong> <span class="trac-field-old">Bugs</span> → <span class="trac-field-new">Patches</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">wontfix</span> </li> </ul> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/5522#comment:2" title="Comment 2">eric_niebler</a>: </p> <blockquote class="citation"> <p> I believe gcc is warning about perfectly valid code. There is no other way to detect const rvalues in C++98 that I'm aware of. I don't know how to fix this, and using <code>_Pragma</code> to suppress the warning didn't work. I'm sorry, I don't think this is fixable. </p> <p> If you come up with a patch, please reopen this ticket. Thanks. </p> </blockquote> <p> Reopened, see previous comment </p> Ticket Steven Watanabe Fri, 04 Apr 2014 18:34:26 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/5522#comment:5 https://svn.boost.org/trac10/ticket/5522#comment:5 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">wontfix</span> </li> </ul> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/5522#comment:3" title="Comment 3">anonymous</a>: </p> <blockquote class="citation"> <p> I'm assuming the compiler will optimize out the v<span class="underline">LINE</span> variables. </p> </blockquote> <p> It's extremely unlikely. This workaround is also completely unsuitable for inclusion in the library. </p> Ticket