Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#11541 closed Bugs (fixed)

Building with /Zc:wchar_t- on VC causes errors in boost::log since 1.59.0

Reported by: dd0t@… Owned by: Andrey Semashev
Milestone: To Be Determined Component: log
Version: Boost 1.59.0 Severity: Regression
Keywords: Cc:

Description

Boost 1.58.0 and earlier could be built successfully with '/Zc:wchar_t-' (no native wchar_t type) set. Since boost 1.59.0 this causes template errors in boost log. More specifically in code_conversion.hpp . I'm not quite clear on whether boost is actually interested in being able to build with this flag enabled in the first place, however I won't be the only one seeing this regression as it isn't unusual for this flag to be present in Windows projects. For example Qt was built with it throughout the 4.X series and most old systems with some MFC dependency set it at some point to retain binary compatibility.

Here one of the error messages from Visual Studio 2013 (VC12) for reference (looks pretty much the same for VC14):

.\boost/log/detail/code_conversion.hpp(114) : error C2784: 'boost::enable_if_c<boost::log::v2s_mt_nt5::aux::is_character_type<T>::value&&boost::log::v2s_mt_nt5::aux::is_character_type<TargetCharT>::value&&sizeof(SourceCharT)!=sizeof(TargetCharT),void>::type boost::log::v2s_mt_nt5::aux::code_convert(const SourceCharT *,size_t,std::basic_string<TargetCharT,TargetTraitsT,TargetAllocatorT> &,const std::locale &)' : could not deduce template argument for 'const SourceCharT *' from 'const std::wstring'
        .\boost/log/detail/code_conversion.hpp(93) : see declaration of 'boost::log::v2s_mt_nt5::aux::code_convert'
.\boost/log/detail/code_conversion.hpp(114) : error C2893: Failed to specialize function template 'boost::enable_if_c<boost::log::v2s_mt_nt5::aux::is_character_type<T>::value&&boost::log::v2s_mt_nt5::aux::is_character_type<TargetCharT>::value&&sizeof(SourceCharT)!=sizeof(TargetCharT),void>::type boost::log::v2s_mt_nt5::aux::code_convert(const std::basic_string<_Elem,_Traits,_Alloc> &,std::basic_string<TargetCharT,TargetTraitsT,TargetAllocatorT> &,const std::locale &)'
        With the following template arguments:
        'SourceCharT=wchar_t'
        'SourceTraitsT=std::char_traits<wchar_t>'
        'SourceAllocatorT=std::allocator<wchar_t>'
        'TargetCharT=char'
        'TargetTraitsT=std::char_traits<char>'
        'TargetAllocatorT=std::allocator<char>'

Change History (3)

comment:1 by dd0t@…, 7 years ago

Component: Nonelog
Owner: set to Andrey Semashev

comment:2 by Andrey Semashev, 7 years ago

Resolution: fixed
Status: newclosed

Fixed in https://github.com/boostorg/log/commit/44ef1095051f389931693f5117e404ffe22b9a56.

To answer your question about emulated wchar_t support, I don't think there's much will to support it as this behavior is non-conforming (read: adds unnecessary problems) and can be relatively easily fixed with a compiler switch. Boost itself is built with the native wchar_t enabled, and this has been so for many years. Additionally, there are no testers with emulated wchar_t, so expect breakages.

With respect to Boost.Log, the emulated wchar_t is problematic as it makes certain parts of the library behave differently than normal. I added a note to the docs stating that. For now I fixed the compilation but in the future I may remove support for emulated wchar_t completely. I highly recommend switching to the native wchar_t.

comment:3 by dd0t@…, 7 years ago

Thanks for the quick fix. We are removing the flag with our transition to vc14. Since 1.59.0 is the first boost version to support that compiler being able to compile it with out legacy configuration and compiler makes handling the transition in our dependency management a easier.

Note: See TracTickets for help on using tickets.