[Boost-bugs] [Boost C++ Libraries] #11673: locale: Invalid static_cast

Subject: [Boost-bugs] [Boost C++ Libraries] #11673: locale: Invalid static_cast
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-09-20 08:54:49


#11673: locale: Invalid static_cast
-----------------------------------------------+---------------------
 Reporter: Ben Wiederhake <Ben.Wiederhake@…> | Owner: artyom
     Type: Bugs | Status: new
Milestone: Boost 1.60.0 | Component: locale
  Version: Boost 1.59.0 | Severity: Problem
 Keywords: |
-----------------------------------------------+---------------------
 When trying to compile certain versions of boost (see below which
 versions), I see the following compilation error when using gcc-5.2:

 `libs/locale/src/shared/message.cpp:438:64: error: invalid static_cast
 from type 'const wchar_t*' to type 'const char*'`

 This is the relevant code:

 {{{
 template<typename CharType>
 ...
 CharType const *p = ...;
 CharType const *e = ...;
 ...
 state = pj_winberger_hash::update_state(state,
     static_cast<char const *>(p),
     static_cast<char const *>(e));
 }}}

 In essence, the code tries to *re-interpret* the argument as a sequence of
 chars and feeds it into the `update_state` function of some kind of hash.
 I don't understand all the details, but I'm pretty sure this is not a
 `static_cast` anymore and the compilation error is valid.

 I can see the following options to resolve the issue:
 - Declare any template instantiations with non-char `CharType` as illegal.
 I view this as a very bad if not insane idea.
 - Change it from `static_cast` to `reinterpret_cast` because that's
 precisely what is needed here. I view this as a good idea.

 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.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/11673>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:19 UTC