Boost C++ Libraries: Ticket #3876: %T format specifier with local_time_facet crashes with MSVC 9 https://svn.boost.org/trac10/ticket/3876 <p> The following program crashes with MSVC9 when trying to write the local_date_time to the stringstream: </p> <div class="wiki-code"><div class="code"><pre><span class="cp">#include</span> <span class="cpf">&lt;boost/date_time/local_time/local_time.hpp&gt; </span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;iostream&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;string&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;sstream&gt;</span><span class="cp"></span> <span class="kt">int</span> <span class="nf">main</span><span class="p">()</span> <span class="p">{</span> <span class="k">using</span> <span class="k">namespace</span> <span class="n">boost</span><span class="o">::</span><span class="n">posix_time</span><span class="p">;</span> <span class="k">using</span> <span class="k">namespace</span> <span class="n">boost</span><span class="o">::</span><span class="n">local_time</span><span class="p">;</span> <span class="n">time_zone_ptr</span> <span class="n">utc</span><span class="p">;</span> <span class="n">local_date_time</span> <span class="n">now</span><span class="p">(</span><span class="n">microsec_clock</span><span class="o">::</span><span class="n">universal_time</span><span class="p">(),</span> <span class="n">utc</span><span class="p">);</span> <span class="n">local_time_facet</span><span class="o">*</span> <span class="n">output_facet</span> <span class="o">=</span> <span class="k">new</span> <span class="n">local_time_facet</span><span class="p">();</span> <span class="n">local_time_input_facet</span><span class="o">*</span> <span class="n">input_facet</span> <span class="o">=</span> <span class="k">new</span> <span class="n">local_time_input_facet</span><span class="p">();</span> <span class="n">std</span><span class="o">::</span><span class="n">stringstream</span> <span class="n">ss</span><span class="p">;</span> <span class="n">ss</span><span class="p">.</span><span class="n">imbue</span><span class="p">(</span><span class="n">std</span><span class="o">::</span><span class="n">locale</span><span class="p">(</span><span class="n">std</span><span class="o">::</span><span class="n">locale</span><span class="o">::</span><span class="n">classic</span><span class="p">(),</span> <span class="n">output_facet</span><span class="p">));</span> <span class="n">ss</span><span class="p">.</span><span class="n">imbue</span><span class="p">(</span><span class="n">std</span><span class="o">::</span><span class="n">locale</span><span class="p">(</span><span class="n">ss</span><span class="p">.</span><span class="n">getloc</span><span class="p">(),</span> <span class="n">input_facet</span><span class="p">));</span> <span class="c1">// http://www.boost.org/doc/libs/1_41_0/doc/html/date_time/date_time_io.html#date_time.format_flags</span> <span class="c1">// %T ! The time in 24-hour notation (%H:%M:%S)</span> <span class="n">output_facet</span><span class="o">-&gt;</span><span class="n">format</span><span class="p">(</span><span class="s">&quot;%T&quot;</span><span class="p">);</span> <span class="n">ss</span> <span class="o">&lt;&lt;</span> <span class="n">now</span><span class="p">;</span> <span class="c1">// crash in _Strftime_l</span> <span class="p">}</span> </pre></div></div><p> With MinGW 4.4.0 it just ignores the %T format specifier. What's the deal with %T? </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3876 Trac 1.4.3 Andrey Semashev Sat, 05 Jun 2010 09:04:47 GMT <link>https://svn.boost.org/trac10/ticket/3876#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3876#comment:1</guid> <description> <p> This placeholder is not standard, but Boost.<a class="missing wiki">DateTime</a> doesn't handle it itself. This should either be mentioned in docs or fixed in the code. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Andrey Semashev</dc:creator> <pubDate>Sat, 05 Jun 2010 17:09:43 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/3876#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3876#comment:2</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/62450" title="Refs #3876. Made format flags %T and %R to be processed by the library ...">[62450]</a>) Refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3876" title="#3876: Bugs: %T format specifier with local_time_facet crashes with MSVC 9 (closed: fixed)">#3876</a>. Made format flags %T and %R to be processed by the library in order to support them on more platforms. Also marked some flags that are known to have similar problems in the docs. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Andrey Semashev</dc:creator> <pubDate>Wed, 09 Jun 2010 16:33:39 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/3876#comment:3 https://svn.boost.org/trac10/ticket/3876#comment:3 <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> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/62667" title="Merged changes from trunk (rev. 62450). Fixes #3876.">[62667]</a>) Merged changes from trunk (rev. 62450). Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3876" title="#3876: Bugs: %T format specifier with local_time_facet crashes with MSVC 9 (closed: fixed)">#3876</a>. </p> Ticket Andrey Semashev Wed, 09 Jun 2010 16:39:32 GMT <link>https://svn.boost.org/trac10/ticket/3876#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3876#comment:4</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/62669" title="Merged changes from trunk (rev. 62450). Fixes #3876. ">[62669]</a>) Merged changes from trunk (rev. 62450). Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3876" title="#3876: Bugs: %T format specifier with local_time_facet crashes with MSVC 9 (closed: fixed)">#3876</a>. </p> </description> <category>Ticket</category> </item> </channel> </rss>