Boost C++ Libraries: Ticket #7949: Level 4 Warnings with VS2005 https://svn.boost.org/trac10/ticket/7949 <p> Try to compile the following with /W4 under VS2005: </p> <pre class="wiki">#include "boost/lexical_cast.hpp" #include "boost/date_time.hpp" </pre><p> This will give you a bunch of warnings: </p> <pre class="wiki">\boost\lexical_cast.hpp(732) : warning C4244: '+=' : conversion from 'int' to 'unsigned short', possible loss of data \boost\lexical_cast.hpp(1627) : see reference to function template instantiation 'bool boost::detail::lcast_ret_unsigned&lt;Traits,Type,CharT&gt;(T &amp;,const CharT *const ,const CharT *)' being compiled \boost\lexical_cast.hpp(1751) : see reference to function template instantiation 'bool boost::detail::lexical_stream_limited_src&lt;CharT,Traits,RequiresStringbuffer&gt;::shr_unsigned&lt;unsigned short&gt;(Type &amp;)' being compiled \boost\lexical_cast.hpp(1751) : while compiling class template member function 'bool boost::detail::lexical_stream_limited_src&lt;CharT,Traits,RequiresStringbuffer&gt;::operator &gt;&gt;(unsigned short &amp;)' \boost\lexical_cast.hpp(2137) : see reference to class template instantiation 'boost::detail::lexical_stream_limited_src&lt;CharT,Traits,RequiresStringbuffer&gt;' being compiled \boost\lexical_cast.hpp(2083) : while compiling class template member function 'unsigned short boost::detail::lexical_cast_do_cast&lt;Target,Source&gt;::lexical_cast_impl(const Source &amp;)' \boost\lexical_cast.hpp(2300) : see reference to class template instantiation 'boost::detail::lexical_cast_do_cast&lt;Target,Source&gt;' being compiled \boost\date_time\date_parsing.hpp(138) : see reference to function template instantiation 'Target boost::lexical_cast&lt;unsigned short,Type&gt;(const Source &amp;)' being compiled \boost\date_time\gregorian\parsers.hpp(30) : see reference to function template instantiation 'date_type boost::date_time::parse_date&lt;boost::gregorian::date&gt;(const std::string &amp;,int)' being compiled \boost\lexical_cast.hpp(780) : warning C4244: '+=' : conversion from 'int' to 'unsigned short', possible loss of data </pre><p> Attached a patch which silences these, as is done in other libraries. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7949 Trac 1.4.3 Peter Brockamp <p.brockamp@…> Tue, 29 Jan 2013 12:46:46 GMT attachment set https://svn.boost.org/trac10/ticket/7949 https://svn.boost.org/trac10/ticket/7949 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">lexical_cast.hpp.diff</span> </li> </ul> <p> Silence warning C4244 under VS2005 </p> Ticket Antony Polukhin Tue, 29 Jan 2013 17:10:49 GMT status, milestone changed https://svn.boost.org/trac10/ticket/7949#comment:1 https://svn.boost.org/trac10/ticket/7949#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.54.0</span> </li> </ul> Ticket Antony Polukhin Fri, 01 Feb 2013 07:16:35 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/7949#comment:2 https://svn.boost.org/trac10/ticket/7949#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">wontfix</span> </li> </ul> <p> This is a bug of VS2005, it is fixed in VS2012 (may be also fixed in earlier versions of VS). Working around buggy warnings on non default warning level - I don't think that it is worth doing in lexical_cast. </p> Ticket Peter Brockamp <p.brockamp@…> Fri, 01 Feb 2013 09:58:56 GMT <link>https://svn.boost.org/trac10/ticket/7949#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7949#comment:3</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/7949#comment:2" title="Comment 2">apolukhin</a>: </p> <blockquote class="citation"> <p> Working around buggy warnings on non default warning level - I don't think that it is worth doing in lexical_cast. </p> </blockquote> <p> Well, maybe it is not, yes. Admittedly this particular warning is rather braindead under some circumstances (notably more or less unneccessary integer promotion done by the compiler behind the scenes. Short int seems to be treated as a second class citizen here). Anyway, consider: </p> <ul><li>The problem with warnings coming from headers of course is that they often will popup in every including cpp-file or at every place an certain template instance is used, cluttering the build output and hindering/demotivating programmers fixing their selfmade warnings. </li><li>There are companies that implement a zero-warning-policy - they have a reason to do so. </li><li>"Tightening the screws" on programmers by increasing the warning level <strong>is</strong> a useful thing, it often leads the way to uncover hidden, subtle bugs. </li><li>Boost itself states they intend to make warning free headers for every supported compiler - with additional warnings enabled (/W4, -Wall, etc.). </li><li>Many programmers unfortunately are bound to a certain compiler/compiler version - and to being molested by the warnings it emmits, no matter whether they're buggy or not. </li></ul><p> So that's why I submitted this, and the patch is just a #pragma to shut down the warnings in lexical_cast, no line of production code is being changed. But never mind, that's just my personal opinion and everyone's summoned to have their personal opinion. </p> <p> Best regards </p> <p> Peter </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Antony Polukhin</dc:creator> <pubDate>Fri, 01 Feb 2013 11:48:17 GMT</pubDate> <title>status changed; resolution deleted https://svn.boost.org/trac10/ticket/7949#comment:4 https://svn.boost.org/trac10/ticket/7949#comment:4 <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">wontfix</span> </li> </ul> <p> OK, you convinced me. But I'll disable this warning only for VS2005 (_MSC_VER == 1400). If you could reproduce it on VS2008, I'll also fix it there. </p> Ticket Peter Brockamp <p.brockamp@…> Fri, 01 Feb 2013 13:12:21 GMT <link>https://svn.boost.org/trac10/ticket/7949#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7949#comment:5</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/7949#comment:4" title="Comment 4">apolukhin</a>: </p> <blockquote class="citation"> <p> OK, you convinced me. But I'll disable this warning only for VS2005 (_MSC_VER == 1400). </p> </blockquote> <p> Yep, that's fine. </p> <blockquote class="citation"> <p> If you could reproduce it on VS2008, I'll also fix it there. </p> </blockquote> <p> Sorry, but this is a no-op for me! I do not have access to VS2008 (AKA for the time being I'm bound to VS2005 &amp; gcc 4.3.3 (<a class="missing wiki">WindRiver</a> version, somehow patched for vxWorks) and may not simply install an express edition of VS2008 or whatever) :-/ </p> <p> Someone else has to check whether this poses a problem in VS2008, too. Of course I could install VS at home for testing purposes - but everybody wants to call it a day eventually, so do I. &lt;irony&gt; You don't want my wife to punish me, do you? &lt;/irony&gt; ;-&gt; </p> <p> Best regards </p> <p> Peter </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Antony Polukhin</dc:creator> <pubDate>Sun, 10 Feb 2013 13:59:47 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7949#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7949#comment:6</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/82807" title="Silence some buggy VS warnings (refs #7949)">[82807]</a>) Silence some buggy VS warnings (refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7949" title="#7949: Bugs: Level 4 Warnings with VS2005 (closed: fixed)">#7949</a>) </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Antony Polukhin</dc:creator> <pubDate>Sun, 24 Feb 2013 08:31:19 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/7949#comment:7 https://svn.boost.org/trac10/ticket/7949#comment:7 <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> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/83114" title="Merge from trunk: * Silence some buggy VS warnings (fixes #7949) * Fix ...">[83114]</a>) Merge from trunk: </p> <ul><li>Silence some buggy VS warnings (fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7949" title="#7949: Bugs: Level 4 Warnings with VS2005 (closed: fixed)">#7949</a>) </li><li>Fix -Wconversion warnings (fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2558" title="#2558: Bugs: Unnecessary conversion warning in lexical_cast (closed: fixed)">#2558</a>) </li><li>Added support for int128 conversions (fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7909" title="#7909: Feature Requests: Add support for conversions of int128 types (closed: fixed)">#7909</a>) </li></ul> Ticket