Boost C++ Libraries: Ticket #8120: DONT_USE_HAS_NEW_OPERATOR warning with MSVC and Intel compiler https://svn.boost.org/trac10/ticket/8120 <p> I get the following warning relating to the <strong>DONT_USE_HAS_NEW_OPERATOR</strong> macro: </p> <pre class="wiki">boost/archive/detail/iserializer.hpp(69): warning #3199: "defined" is always false in a macro expansion in Microsoft mode </pre><p> I can reproduce this warning when using Intel Compiler 13.1 with VS2010. Previous versions of Intel compiler did not emit this warning. </p> <p> However the warning appears to be correct as use of <strong>defined</strong> in a macro expansion is undefined by the standard. I also confirmed with a few tests that MSVC always evaluates such macros to false. </p> <p> The solution I am using to fix this warning is to is replace all the uses of <strong>defined</strong> in the <strong>DONT_USE_HAS_NEW_OPERATOR</strong> macro with a comparison to 0. For example instead of </p> <pre class="wiki">defined(__BORLANDC__) </pre><p> use </p> <pre class="wiki">__BORLANDC__ != 0 </pre><p> </p> <p> </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8120 Trac 1.4.3 Robert Ramey Mon, 25 Feb 2013 19:40:10 GMT <link>https://svn.boost.org/trac10/ticket/8120#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8120#comment:1</guid> <description> <p> Hmmm that might be a big issue. I believe that defined(..) is used through out the code since it was more robust than checking a value. It never occurred to me that it wasn't supported by the standard. Maybe we should file an report to the standard. </p> <p> How many instances of "defined(...)" did you have to change? </p> <p> Robert Ramey </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Steven Watanabe</dc:creator> <pubDate>Tue, 26 Feb 2013 15:02:17 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8120#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8120#comment:2</guid> <description> <p> defined(...) only works at the top level inside #ifdefs. "If the token defined is generated as a result of this replacement process ... the behavior is undefined" (C++11 16.2) However, using <span class="underline">XXX</span> != 0 will also generate warnings. I believe that BOOST_WORKAROUND is safe to use. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Robert Ramey</dc:creator> <pubDate>Mon, 03 Feb 2014 22:52:54 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/8120#comment:3 https://svn.boost.org/trac10/ticket/8120#comment:3 <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> I've removed this macro so I think this is no longer an issue </p> Ticket andre@… Sun, 30 Aug 2015 11:13:16 GMT status, version changed; resolution deleted https://svn.boost.org/trac10/ticket/8120#comment:4 https://svn.boost.org/trac10/ticket/8120#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>version</strong> <span class="trac-field-old">Boost 1.49.0</span> → <span class="trac-field-new">Boost 1.59.0</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">fixed</span> </li> </ul> <p> Hello </p> <p> The issue is still there with boost 1.59 In line 60 of boost\archive\detail\iserializer.hpp there is still the code: </p> <pre class="wiki">#define DONT_USE_HAS_NEW_OPERATOR ( \ BOOST_WORKAROUND(__IBMCPP__, &lt; 1210) \ || defined(__SUNPRO_CC) &amp;&amp; (__SUNPRO_CC &lt; 0x590) \ ) </pre><p> And the Intel Compiler 15.0 together with Visual Studio 2015 produces the warning: .\boost/archive/detail/iserializer.hpp(64): warning #3199: "defined" is always false in a macro expansion in Microsoft mode So from my point of view the "bug" has not been fixed and this thread does not contain a workaround for fixing it. That's why I reopened this ticket. </p> <p> Best regards </p> Ticket Robert Ramey Mon, 28 Sep 2015 05:31:29 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/8120#comment:5 https://svn.boost.org/trac10/ticket/8120#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">invalid</span> </li> </ul> <p> This produces a warning for microsoft and intel in microsoft mode. </p> <p> The warning is of no value and can be safely ignored. Eliminating this code break code for ibm and sunpro compilers. If ths really bugs you, you can submit a patch which eliminates the bogus warning without breaking code for other compilers. </p> Ticket Andre Netzeband <andre@…> Mon, 28 Sep 2015 08:20:24 GMT status changed; resolution deleted https://svn.boost.org/trac10/ticket/8120#comment:6 https://svn.boost.org/trac10/ticket/8120#comment:6 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">invalid</span> </li> </ul> <p> Hello </p> <p> From my point of view it is still a bug. MSVC thinks this code is wrong or at least suspicious, that why it throws this warning. From the warning text and also from the context of this code, it is not clear to me if the preprocessor really does the right thing here. </p> <p> Well, you said the warning can be ignored, because the preprocessor will do everything right. That's ok... so the warning it not an impediment for users, that do not treat warning as errors. However the code is still not correct for MSVC and should be fixed in any further release. </p> <p> I clearly understand, that fixing the code might be risky and could not be done very fast. That's why I think you should give a low priority to it, but you should not forget it or just close your eyes and hope there will never be an error due to that. </p> <p> Best regards </p> Ticket Robert Ramey Mon, 28 Sep 2015 21:55:11 GMT <link>https://svn.boost.org/trac10/ticket/8120#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8120#comment:7</guid> <description> <p> I'm trying the following instead. I can't test it, so you should. Let me know how this works </p> <pre class="wiki">#ifndef BOOST_MSVC #define DONT_USE_HAS_NEW_OPERATOR ( \ BOOST_WORKAROUND(__IBMCPP__, &lt; 1210) \ || defined(__SUNPRO_CC) &amp;&amp; (__SUNPRO_CC &lt; 0x590) \ ) #else #define DONT_USE_HAS_NEW_OPERATOR 0 #endif </pre> </description> <category>Ticket</category> </item> <item> <author>Andre Netzeband <andre@…></author> <pubDate>Tue, 29 Sep 2015 12:54:21 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8120#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8120#comment:8</guid> <description> <p> With this fix the warning is not there anymore. Tested with Intel 16.0 and MSVC2015 compiler. </p> <p> Thanks :-) </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Robert Ramey</dc:creator> <pubDate>Tue, 29 Sep 2015 20:14:23 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/8120#comment:9 https://svn.boost.org/trac10/ticket/8120#comment:9 <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">fixed</span> </li> </ul> Ticket