Boost C++ Libraries: Ticket #5507: const char vs. const signed char in boost/archive/iterators/binary_from_base64.hpp https://svn.boost.org/trac10/ticket/5507 <p> There seems to be a small bug in binary_from_base64.hpp: </p> <pre class="wiki"> CharType operator()(CharType t) const{ const char lookup_table[] = { -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, [...] </pre><p> However, it's not guaranteed that a "const char" accepts signed values, see e.g. <a class="ext-link" href="http://www.network-theory.co.uk/docs/gccintro/gccintro_71.html"><span class="icon">​</span>http://www.network-theory.co.uk/docs/gccintro/gccintro_71.html</a>. See also /usr/include/limits.h - depending whether <code>__CHAR_UNSIGNED__</code> is set or not, the platform may not or may accept negative values for a const char. </p> <p> Especially when enabling C++0x support, this leads to a compilation failure e.g. on PowerPC: </p> <pre class="wiki">"powerpc-linux-gnu-g++" -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -pthread -fPIC -std=c++0x -DBOOST_ALL_NO_LIB=1 -DBOOST_SERIALIZATION_DYN_LINK=1 -DNDEBUG -I"." -c -o "bin.v2/libs/serialization/build/gcc-powerpc/release/threading-multi/basic_text_iprimitive.o" "libs/serialization/src/basic_text_iprimitive.cpp" [...] In file included from ./boost/archive/impl/basic_text_iprimitive.ipp:30:0, from libs/serialization/src/basic_text_iprimitive.cpp:19: [...] ./boost/archive/iterators/binary_from_base64.hpp:51:9: error: narrowing conversion of '-0x00000000000000001' from 'int' to 'const char' inside { } </pre><p> The following patch fixed the problem for us: </p> <pre class="wiki">Index: boost_1_46_1/boost/archive/iterators/binary_from_base64.hpp =================================================================== --- boost_1_46_1.orig/boost/archive/iterators/binary_from_base64.hpp +++ boost_1_46_1/boost/archive/iterators/binary_from_base64.hpp @@ -39,7 +39,7 @@ template&lt;class CharType&gt; struct to_6_bit { typedef CharType result_type; CharType operator()(CharType t) const{ - const char lookup_table[] = { + const signed char lookup_table[] = { -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63, </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5507 Trac 1.4.3 Robert Ramey Sun, 31 Jul 2011 17:58:40 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/5507#comment:1 https://svn.boost.org/trac10/ticket/5507#comment:1 <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> looks good to me, I'm rolling in your change. It will likely show up in 1.48 </p> Ticket