Boost C++ Libraries: Ticket #6635: Boost.Locale UTF encode function passes wrong type to output iterator https://svn.boost.org/trac10/ticket/6635 <p> When passing a char output iterator (such as <code>std::back_insert_iterator&lt;std::string&gt;</code>) to <code>boost::locale::utf::utf_traits&lt;char&gt;::encode</code>, the compiler (Apple LLVM compiler 3.1 in Xcode 4.3 with extra warnings enabled) emits a warning about assigning <code>unsigned int</code> to <code>char</code>. The code incorrectly attempts to write the code unit to the output as a <code>code_point</code> instead of a <code>CharType</code>. </p> <p> The attached patch performs a safe static cast of each code unit to <code>CharType</code> as it is written to the output iterator. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6635 Trac 1.4.3 jason.erb@… Wed, 29 Feb 2012 05:38:10 GMT attachment set https://svn.boost.org/trac10/ticket/6635 https://svn.boost.org/trac10/ticket/6635 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">6635.patch</span> </li> </ul> <p> Patch for <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6635" title="#6635: Bugs: Boost.Locale UTF encode function passes wrong type to output iterator (closed: fixed)">#6635</a> </p> Ticket Artyom Beilis Wed, 29 Feb 2012 07:41:03 GMT status, severity, milestone changed https://svn.boost.org/trac10/ticket/6635#comment:1 https://svn.boost.org/trac10/ticket/6635#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> <li><strong>severity</strong> <span class="trac-field-old">Problem</span> → <span class="trac-field-new">Cosmetic</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.50.0</span> </li> </ul> <p> AFAIK there should be no warning for conversion between integral and character type. It is done all over the code in all places. </p> <p> Casting to char_type would eliminate the warning but I'm not sure it is the correct approach. </p> <p> I'll think about it. </p> Ticket Jason Erb <jason.erb@…> Wed, 29 Feb 2012 14:44:27 GMT <link>https://svn.boost.org/trac10/ticket/6635#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6635#comment:2</guid> <description> <p> Thanks for looking into this. Here is the specific message: </p> <p> <code>error: implicit conversion loses integer precision: 'code_point' (aka 'unsigned int') to 'const char' [-Werror,-Wconversion]</code> </p> <p> I have used various boost libraries for a long time with these warnings enabled and this is the first library in which I have hit this problem. In my view, the cast is entirely appropriate in this case: the user has specified <code>CharType</code> as the code unit type, so the code units sent to the output iterator should be of this type. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Artyom Beilis</dc:creator> <pubDate>Wed, 02 May 2012 13:29:34 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6635#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6635#comment:3</guid> <description> <p> Fixed in changeset <a class="missing ticket">#78304</a> in trunk </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Artyom Beilis</dc:creator> <pubDate>Wed, 02 May 2012 13:49:51 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/6635#comment:4 https://svn.boost.org/trac10/ticket/6635#comment:4 <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">fixed</span> </li> </ul> Ticket