Boost C++ Libraries: Ticket #9810: boost serialization: deserialization from boost txt archive fails on -nan for double https://svn.boost.org/trac10/ticket/9810 <p> A double gets correctly serialized to "-nan". Deserializing it leads to 'boost::archive::archive_exception' </p> <blockquote> <p> what(): input stream error </p> </blockquote> <p> when used with a text archive. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/9810 Trac 1.4.3 viboes Wed, 02 Apr 2014 21:19:03 GMT component changed; owner set https://svn.boost.org/trac10/ticket/9810#comment:1 https://svn.boost.org/trac10/ticket/9810#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">Robert Ramey</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">serialization</span> </li> </ul> Ticket Robert Ramey Mon, 07 Apr 2014 15:47:41 GMT status, type changed; resolution set https://svn.boost.org/trac10/ticket/9810#comment:2 https://svn.boost.org/trac10/ticket/9810#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>type</strong> <span class="trac-field-old">Bugs</span> → <span class="trac-field-new">Feature Requests</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">wontfix</span> </li> </ul> <p> this has been discussed for years. It's not a problem of the serialization library per se. It's an effect of the fact that there is no standard/portable way for text based streams to represent various types of NaN s. no one has shown an interest is addressing this. So for now the best policy is to trap attempts so serialize Nan's to text base archives. I had thought we did that on serialization. Maybe you would like to investigate this in more detail </p> <p> Robert Ramey </p> Ticket anonymous Mon, 07 Apr 2014 15:50:13 GMT <link>https://svn.boost.org/trac10/ticket/9810#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9810#comment:3</guid> <description> <p> Sorry but that is not current behavior. Boost happily serializes -nan to -nan in a text format (it looks like 5 6 -8 -nan 8 2 ...), just the deserializing fails. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Robert Ramey</dc:creator> <pubDate>Wed, 25 Jun 2014 16:28:44 GMT</pubDate> <title>status changed; resolution deleted https://svn.boost.org/trac10/ticket/9810#comment:4 https://svn.boost.org/trac10/ticket/9810#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">wontfix</span> </li> </ul> Ticket hdeanclark@… Mon, 14 Mar 2016 21:31:49 GMT <link>https://svn.boost.org/trac10/ticket/9810#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9810#comment:5</guid> <description> <p> I was taken by this behaviour also (in Serialization 1.60). Serialization was fine (to binary, text, and XML), but deserialization of text and XML choke due to NaN and +-Inf. A workaround is to imbue the stream with a facet so that non-finite values are correctly parsed <a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">[1]</a>. Boost.Math provides such a facet: boost::math::nonfinite_num_get (and ...put). See documentation at <a class="changeset" href="https://svn.boost.org/trac10/changeset/2" title="Add Boost Disclaimer">[2]</a>. </p> <p> There is a nice posting at <a class="changeset" href="https://svn.boost.org/trac10/changeset/3" title="Tweak disclaimer text">[3]</a> showing how to use this facet and where to provide the Boost Serialization codecvt option. </p> <p> --- </p> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">[1]</a> Note that NaN payloads are not necessarily restored exactly, but they will be restored to _some_ NaN, depending on the platform. (I believe this issue was a major factor in omission from Serialization.) See the facet documentation for more information. </p> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/2" title="Add Boost Disclaimer">[2]</a> <a href="http://www.boost.org/doc/libs/1_50_0/libs/math/doc/sf_and_dist/html/math_toolkit/utils/fp_facets/intro.html">http://www.boost.org/doc/libs/1_50_0/libs/math/doc/sf_and_dist/html/math_toolkit/utils/fp_facets/intro.html</a> </p> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/3" title="Tweak disclaimer text">[3]</a> <a class="ext-link" href="http://stackoverflow.com/questions/22203496/deserialization-of-non-finite-floating-point-numbers-fails-even-with-appropriate"><span class="icon">​</span>http://stackoverflow.com/questions/22203496/deserialization-of-non-finite-floating-point-numbers-fails-even-with-appropriate</a> </p> </description> <category>Ticket</category> </item> </channel> </rss>