Boost C++ Libraries: Ticket #5793: [date_time] format_date_parser::parse_date does not compile with "Treat wchar_t as builtin type" set to No https://svn.boost.org/trac10/ticket/5793 <p> Testing with Boost 1.47, though it reproduces with trunk as of 19/aug/2011. </p> <p> Visual Studio 2008 / 2010; the following code does not compile when built with "treat wchar_t as builtin type=no" set in project settings: </p> <pre class="wiki">#include &lt;boost/date_time/gregorian/gregorian.hpp&gt; #include &lt;boost/date_time/posix_time/posix_time.hpp&gt; void parseDate() { std::locale locale; boost::date_time::format_date_parser&lt;boost::gregorian::date, wchar_t&gt; parser(L"", locale); boost::date_time::special_values_parser&lt;boost::gregorian::date, wchar_t&gt; svp; boost::gregorian::date date = parser.parse_date(L"", L"", svp); } </pre><blockquote> <p> The compile error is: </p> </blockquote> <pre class="wiki">c:\source\boost\trunk\boost\lexical_cast.hpp(1406): error C2535: 'bool boost::detail::lexical_stream_limited_src&lt;CharT,Traits,RequiresStringbuffer&gt;::operator &gt;&gt;(unsigned short &amp;)' : member function already defined or declared with [ CharT=char_type, Traits=traits, RequiresStringbuffer=false ] c:\source\boost\trunk\boost\lexical_cast.hpp(1392) : see declaration of 'boost::detail::lexical_stream_limited_src&lt;CharT,Traits,RequiresStringbuffer&gt;::operator &gt;&gt;' with [ CharT=char_type, Traits=traits, RequiresStringbuffer=false ] c:\source\boost\trunk\boost\lexical_cast.hpp(1687) : see reference to class template instantiation 'boost::detail::lexical_stream_limited_src&lt;CharT,Traits,RequiresStringbuffer&gt;' being compiled with [ CharT=char_type, Traits=traits, RequiresStringbuffer=false ] c:\source\boost\trunk\boost\lexical_cast.hpp(1653) : while compiling class template member function 'short boost::detail::lexical_cast_do_cast&lt;Target,Source&gt;::lexical_cast_impl(const Source &amp;)' with [ Target=short, Source=src ] c:\source\boost\trunk\boost\lexical_cast.hpp(1858) : see reference to class template instantiation 'boost::detail::lexical_cast_do_cast&lt;Target,Source&gt;' being compiled with [ Target=short, Source=src ] c:\source\boost\trunk\boost\date_time\format_date_parser.hpp(72) : see reference to function template instantiation 'Target boost::lexical_cast&lt;int_type,std::basic_string&lt;_Elem,_Traits,_Ax&gt;&gt;(const Source &amp;)' being compiled with [ Target=short, int_type=short, _Elem=wchar_t, _Traits=std::char_traits&lt;wchar_t&gt;, _Ax=std::allocator&lt;wchar_t&gt;, Source=std::basic_string&lt;wchar_t,std::char_traits&lt;wchar_t&gt;,std::allocator&lt;wchar_t&gt;&gt; ] c:\source\boost\trunk\boost\date_time\format_date_parser.hpp(365) : see reference to function template instantiation 'int_type boost::date_time::fixed_string_to_int&lt;short,charT&gt;(std::istreambuf_iterator&lt;_Elem,_Traits&gt; &amp;,std::istreambuf_iterator&lt;_Elem,_Traits&gt; &amp;,boost::date_time::parse_match_result&lt;charT&gt; &amp;,unsigned int,const charT &amp;)' being compiled with [ int_type=short, charT=wchar_t, _Elem=wchar_t, _Traits=std::char_traits&lt;wchar_t&gt; ] c:\source\boost\trunk\boost\date_time\format_date_parser.hpp(254) : while compiling class template member function 'boost::gregorian::date boost::date_time::format_date_parser&lt;date_type,charT&gt;::parse_date(std::istreambuf_iterator&lt;_Elem,_Traits&gt; &amp;,std::istreambuf_iterator&lt;_Elem,_Traits&gt; &amp;,std::basic_string&lt;_Elem,_Traits,_Ax&gt;,const boost::date_time::special_values_parser&lt;date_type,charT&gt; &amp;) const' with [ date_type=boost::gregorian::date, charT=wchar_t, _Elem=wchar_t, _Traits=std::char_traits&lt;wchar_t&gt;, _Ax=std::allocator&lt;wchar_t&gt; ] c:\source\dan\boost_wchar_t_test\boost_wchar_t_test\boost_wchar_t_test.cpp(9) : see reference to class template instantiation 'boost::date_time::format_date_parser&lt;date_type,charT&gt;' being compiled with [ date_type=boost::gregorian::date, charT=wchar_t ] </pre><blockquote> <p> If I set "Treat wchar_t as builtin type" to Yes, then it does compile correctly. </p> </blockquote> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5793 Trac 1.4.3 Ulrich Eckhardt <ulrich.eckhardt@…> Tue, 31 Jan 2012 08:58:09 GMT owner, component changed https://svn.boost.org/trac10/ticket/5793#comment:1 https://svn.boost.org/trac10/ticket/5793#comment:1 <ul> <li><strong>owner</strong> changed from <span class="trac-author">az_sw_dude</span> to <span class="trac-author">Antony Polukhin</span> </li> <li><strong>component</strong> <span class="trac-field-old">date_time</span> → <span class="trac-field-new">lexical_cast</span> </li> </ul> <p> Note to the submitter: You are deliberately configuring your compiler to not conform to the C++ standard which requires wchar_t to be a distinct type! </p> <p> Anyway, I don't think this is a problem in the DateTime library but rather in the lexical_cast implementation. The simple line </p> <pre class="wiki">std::wstring x = boost::lexical_cast&lt;std::wstring&gt;(42); </pre><p> triggers the fault for me. Class lexical_stream_limited_src is instantiated for wchar_t alias unsigned short. It defines an operator&gt;&gt; for both unsigned short and its CharT which then cause the conflict. The macro BOOST_NO_INTRINSIC_WCHAR_T could be used to detect this, but I'm not sure how to fix it without breaking other stuff on the way. </p> Ticket Antony Polukhin Tue, 31 Jan 2012 16:12:32 GMT <link>https://svn.boost.org/trac10/ticket/5793#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5793#comment:2</guid> <description> <p> This looks like bug <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6186" title="#6186: Bugs: lexical_cast on vs2005 with wchar_t- (closed: fixed)">#6186</a> which is already fixed and merged to release branch (1.49)<br /> Added test case from this ticket in <a class="changeset" href="https://svn.boost.org/trac10/changeset/76809" title="New test case from ticket #5793">r76809</a>. If regression tests won't fail, I'll close this bug. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Antony Polukhin</dc:creator> <pubDate>Sat, 04 Feb 2012 18:09:46 GMT</pubDate> <title>status changed; cc, resolution set https://svn.boost.org/trac10/ticket/5793#comment:3 https://svn.boost.org/trac10/ticket/5793#comment:3 <ul> <li><strong>cc</strong> <span class="trac-author">antoshkka@…</span> added </li> <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> Regression tests passed successfully. </p> Ticket