Boost C++ Libraries: Ticket #11673: locale: Invalid static_cast https://svn.boost.org/trac10/ticket/11673 <p> When trying to compile certain versions of boost (see below which versions), I see the following compilation error when using gcc-5.2: </p> <p> <code>libs/locale/src/shared/message.cpp:438:64: error: invalid static_cast from type 'const wchar_t*' to type 'const char*'</code> </p> <p> This is the relevant code: </p> <pre class="wiki">template&lt;typename CharType&gt; ... CharType const *p = ...; CharType const *e = ...; ... state = pj_winberger_hash::update_state(state, static_cast&lt;char const *&gt;(p), static_cast&lt;char const *&gt;(e)); </pre><p> In essence, the code tries to *re-interpret* the argument as a sequence of chars and feeds it into the <code>update_state</code> function of some kind of hash. I don't understand all the details, but I'm pretty sure this is not a <code>static_cast</code> anymore and the compilation error is valid. </p> <p> I can see the following options to resolve the issue: </p> <ul><li>Declare any template instantiations with non-char <code>CharType</code> as illegal. I view this as a very bad if not insane idea. </li><li>Change it from <code>static_cast</code> to <code>reinterpret_cast</code> because that's precisely what is needed here. I view this as a good idea. </li></ul><p> This issue is visible in branch master of boostorg/boost. This issue seems to have been visible since the commit 8f94dbbf3563381ebf1f8db96e16692f8e351db9 ("Inline namespace test version.") in boostorg/type_traits, introduced by commit 9eae98d8714f8cb4114e799bbb4e10f45919dda4 ("Update type_traits from master") in boostorg/boost. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11673 Trac 1.4.3 Ben Wiederhake <Ben.Wiederhake@…> Sun, 20 Sep 2015 09:26:46 GMT <link>https://svn.boost.org/trac10/ticket/11673#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11673#comment:1</guid> <description> <p> Created a PR: <a class="ext-link" href="https://github.com/boostorg/locale/pull/11"><span class="icon">​</span>https://github.com/boostorg/locale/pull/11</a> </p> <p> All regression tests pass. </p> </description> <category>Ticket</category> </item> <item> <author>carsten@…</author> <pubDate>Wed, 23 Sep 2015 13:09:27 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11673#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11673#comment:2</guid> <description> <p> I can confirm the error also for gcc-4.9-2 on armabihf. </p> <pre class="wiki">$ git rev-parse HEAD b7e4885aa091a5b35663cbe30a248048de7a4799 </pre><pre class="wiki">$ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-linux-gnueabihf/4.9/lto-wrapper Target: arm-linux-gnueabihf Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.9.2-10ubuntu13' --with-bugurl=file:///usr/share/doc/gcc-4.9/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.9 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.9 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libitm --disable-libquadmath --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.9-armhf/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.9-armhf --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.9-armhf --with-arch-directory=arm --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --enable-multilib --disable-sjlj-exceptions --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-mode=thumb --disable-werror --enable-multilib --enable-checking=release --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf Thread model: posix gcc version 4.9.2 (Ubuntu/Linaro 4.9.2-10ubuntu13) </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>Artyom Beilis</dc:creator> <pubDate>Thu, 24 Sep 2015 06:27:04 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11673#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11673#comment:3</guid> <description> <p> I almost having deja vu about it. </p> <p> It looks like I changed it at some point to static cast as part of a review. </p> <p> Thanks for the pull. Question is if somebody can push it into release/development branch (I just offline for a while with a boost access need to sort out several things) </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Artyom Beilis</dc:creator> <pubDate>Thu, 24 Sep 2015 19:18:24 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11673#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11673#comment:4</guid> <description> <p> Ok... </p> <p> The problem is actually that before some point boost/version.hpp wasn't even included such that this code had never compiled... </p> <p> It is quite bad. I consider actually removing entire hash stuff because it is less tested. </p> </description> <category>Ticket</category> </item> <item> <author>Akira Takahashi <faithandbrave@…></author> <pubDate>Thu, 12 Nov 2015 05:09:40 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11673#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11673#comment:5</guid> <description> <p> This issue fixed? The issue is listed to Boost 1.60.0 release-note. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Artyom Beilis</dc:creator> <pubDate>Thu, 12 Nov 2015 06:12:53 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/11673#comment:6 https://svn.boost.org/trac10/ticket/11673#comment:6 <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> Fixed in 1.60 </p> Ticket