Boost C++ Libraries: Ticket #5598: boost/property_tree/detail/json_parser_write.hpp:35: warning: comparison is always true due to limited range of data type https://svn.boost.org/trac10/ticket/5598 <p> Here is the relevant output: </p> <pre class="wiki">cc1plus: warnings being treated as errors gcc41_64/include/boost/property_tree/detail/json_parser_write.hpp: In function 'std::basic_string&lt;_CharT, std::char_traits&lt;_CharT&gt;, std::allocator&lt;_CharT&gt; &gt; boost::property_tree::json_parser::create_escapes(const std::basic_string&lt;_CharT, std::char_traits&lt;_CharT&gt;, std::allocator&lt;_CharT&gt; &gt;&amp;) [with Ch = char]': gcc41_64/include/boost/property_tree/detail/json_parser_write.hpp:78: instantiated from 'void boost::property_tree::json_parser::write_json_helper(std::basic_ostream&lt;typename Ptree::key_type::value_type, std::char_traits&lt;typename Ptree::key_type::value_type&gt; &gt;&amp;, const Ptree&amp;, int, bool) [with Ptree = boost::property_tree::basic_ptree&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::less&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt;]' gcc41_64/include/boost/property_tree/detail/json_parser_write.hpp:162: instantiated from 'void boost::property_tree::json_parser::write_json_internal(std::basic_ostream&lt;typename Ptree::key_type::value_type, std::char_traits&lt;typename Ptree::key_type::value_type&gt; &gt;&amp;, const Ptree&amp;, const std::string&amp;, bool) [with Ptree = boost::property_tree::basic_ptree&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::less&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt;]' gcc41_64/include/boost/property_tree/json_parser.hpp:98: instantiated from 'void boost::property_tree::json_parser::write_json(std::basic_ostream&lt;typename Ptree::key_type::value_type, std::char_traits&lt;typename Ptree::key_type::value_type&gt; &gt;&amp;, const Ptree&amp;, bool) [with Ptree = boost::property_tree::basic_ptree&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::less&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt; &gt;]' json.cc:36: instantiated from here gcc41_64/include/boost/property_tree/detail/json_parser_write.hpp:35: warning: comparison is always true due to limited range of data type make: *** [json.o] Error 1 </pre><p> In the big if() statement, *b (of type Ch, which is char) is being compared with 0xFF. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5598 Trac 1.4.3 Sebastian Redl Tue, 07 Jun 2011 17:28:26 GMT <link>https://svn.boost.org/trac10/ticket/5598#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5598#comment:1</guid> <description> <p> Ch might be wchar_t. </p> <p> The warning can be suppressed by casting to some large integer type first, but I feel that the warning here is overeager and a bug. </p> </description> <category>Ticket</category> </item> <item> <author>David Benoit <benoit@…></author> <pubDate>Tue, 07 Jun 2011 17:38:37 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5598#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5598#comment:2</guid> <description> <p> Sorry, I was stating that in my case, Ch was char. Yes, it could be wchar_t as well. However, in the case of Ch being char, the warning is correct. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Mon, 09 Jan 2012 17:53:01 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5598#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5598#comment:3</guid> <description> <p> Please create a comparison function for wide characters and specialize for Ch=char or unsigned char to not perform the comparison *b &lt;= 0xff. </p> <p> Thanks. </p> </description> <category>Ticket</category> </item> <item> <author>Shane Turner <shane.turner@…></author> <pubDate>Wed, 20 Jun 2012 18:12:30 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/5598 https://svn.boost.org/trac10/ticket/5598 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">json_parser_write.hpp.diff</span> </li> </ul> <p> Silence the warning from GCC about a comparison that is always true due to to the limits of the type by creating specializations of the check for char and unsigned char. </p> Ticket Mika Fischer <mika.fischer@…> Thu, 28 Jun 2012 14:52:57 GMT cc set https://svn.boost.org/trac10/ticket/5598#comment:4 https://svn.boost.org/trac10/ticket/5598#comment:4 <ul> <li><strong>cc</strong> <span class="trac-author">mika.fischer@…</span> added </li> </ul> Ticket Matthieu Vachon <matthieu.o.vachon@…> Tue, 25 Jun 2013 22:19:12 GMT attachment set https://svn.boost.org/trac10/ticket/5598 https://svn.boost.org/trac10/ticket/5598 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">json_parser_write.hpp.2.diff</span> </li> </ul> <p> Updated patch for 1.53.0 </p> Ticket Matthieu Vachon <matthieu.o.vachon@…> Tue, 25 Jun 2013 22:27:37 GMT <link>https://svn.boost.org/trac10/ticket/5598#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5598#comment:5</guid> <description> <p> @Shane </p> <p> I attached an updated version of the patch to this tracker. </p> <p> However, the patch fails on my project because I had a double include of <code>&lt;boost/property_tree/json_parser.hpp&gt;</code> in two different compilation units. This caused my program build to fail due to a multiple definition for the <code>check_is_ascii</code> method. I created a simple test case that can be used to reproduce/debug the problem, I can send it to you if you want to. </p> <p> If I have a time, I will check how this could be solved. For now, I just ensured that the <code>json_parser.hpp</code> file is included only once in my codebase. </p> <p> Expect for this, your patch seems to work like a charm. Will report back if I find any problem with it. </p> <p> Regards, Matt </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Mateusz Loskot</dc:creator> <pubDate>Thu, 18 Jul 2013 09:04:07 GMT</pubDate> <title>cc changed https://svn.boost.org/trac10/ticket/5598#comment:6 https://svn.boost.org/trac10/ticket/5598#comment:6 <ul> <li><strong>cc</strong> <span class="trac-author">mateusz@…</span> added </li> </ul> Ticket mk.boost@… Wed, 24 Jul 2013 20:34:21 GMT <link>https://svn.boost.org/trac10/ticket/5598#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5598#comment:7</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/5598#comment:6" title="Comment 6">mloskot</a>: I think, for explicitly instantiated template functions keyword 'inline' would fix the problem </p> </description> <category>Ticket</category> </item> <item> <author>Shane Turner <shane.turner@…></author> <pubDate>Fri, 04 Oct 2013 14:33:14 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5598#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5598#comment:8</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/5598#comment:5" title="Comment 5">Matthieu Vachon &lt;matthieu.o.vachon@…&gt;</a>: Any chance you've tried out adding 'inline' as suggested in <a class="ticket" href="https://svn.boost.org/trac10/ticket/5598#comment:7" title="Comment 7">7</a>? </p> <p> Also, will this change make it into 1.55.0? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>chamara</dc:creator> <pubDate>Tue, 14 Jul 2015 08:16:23 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5598#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5598#comment:9</guid> <description> <p> Can you confirm what version this fix is going to go in? </p> </description> <category>Ticket</category> </item> <item> <author>shane.turner@…</author> <pubDate>Tue, 08 Dec 2015 20:26:25 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/5598 https://svn.boost.org/trac10/ticket/5598 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">json_parser_write.hpp</span> </li> </ul> <p> Updated patch for 1.59.0 </p> Ticket shane.turner@… Mon, 28 Mar 2016 19:08:33 GMT <link>https://svn.boost.org/trac10/ticket/5598#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5598#comment:10</guid> <description> <p> As of Boost 1.61.0 Beta 1 RC2, the file has changed from boost/property_tree/detail/json_parser_write.hpp to boost/property_tree/json_parser/detail/write.hpp </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Tue, 04 Jul 2017 03:44:34 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5598#comment:11 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5598#comment:11</guid> <description> <p> In 1.64.0, the issue happens again, the fix in json_parser_write.hpp.2.diff is lost. </p> </description> <category>Ticket</category> </item> </channel> </rss>