Boost C++ Libraries: Ticket #1778: Possible regression in 1.35 serialization of 2D arrays https://svn.boost.org/trac10/ticket/1778 <p> Our product has been using 1.34.1 for a while with no problems. However, upon upgrading to 1.35, I get the following compile error on MSVC2005 (32bit). </p> <p> <strong>D:\tools\boost\boost_1_35_0\boost/archive/detail/oserializer.hpp(489) : </strong></p> <p> error C2440: 'static_cast' : cannot convert from 'const char (*<span class="underline">w64 )<a class="changeset" href="https://svn.boost.org/trac10/changeset/16" title="*** empty log message *** ">[16]</a>' to 'value_type *<strong>' </strong></span></p> <p> A 2D char array is being serialized as: </p> <pre class="wiki">char c[5][16]; ar &amp; make_nvp("c", c); </pre><hr /> <p> While I don't have but a high-level grasp of MPL, it seems to me that remove_all_extents&lt;T&gt;::type is stripping off all the dimensions, which causes line 489 to fail. </p> <p> If instead, I serialize as: </p> <pre class="wiki">ar &amp; make_nvp("c", make_array(&amp;c[0], sizeof(c)/sizeof(c[0]) ); </pre><p> It of course works. I can do the following as well: </p> <pre class="wiki">ar &amp; make_nvp("c", make_array(&amp;c[0][0], sizeof(c)/sizeof(c[0][0]) ); </pre><hr /> <p> I don't want to use any of the above because there are quite a few of these 2D arrays floating around. They don't contain large blocks of data, so I'm not interested in the make_array optimization at this time. I've created two wrappers which make things a little easier (shamelessly based on your make_array). I can't provide them as make_array overloads because oserializer then erroneously tries to pick one. </p> <pre class="wiki">template&lt;class T, std::size_t M, std::size_t N&gt; inline #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING const #endif array&lt;T[N]&gt; make_array2D( T (&amp; t)[M][N] ) { return array&lt;T[N]&gt;(&amp;t[0], M); } template&lt;class T, std::size_t M, std::size_t N&gt; inline #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING const #endif array&lt;T&gt; make_array2D_flatten( T (&amp; t)[M][N]) { return array&lt;T&gt;(static_cast&lt;T*&gt;(&amp;t[0][0]), N*M); } </pre><hr /> <p> Anyways, just thought I'd let you know what I've run into. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/1778 Trac 1.4.3 dgt@… Sat, 05 Apr 2008 22:07:45 GMT <link>https://svn.boost.org/trac10/ticket/1778#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1778#comment:1</guid> <description> <p> If this is in fact a deliberate regression, then a note in the documentation would be nice :) </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Robert Ramey</dc:creator> <pubDate>Mon, 07 Apr 2008 16:31:07 GMT</pubDate> <title>owner changed https://svn.boost.org/trac10/ticket/1778#comment:2 https://svn.boost.org/trac10/ticket/1778#comment:2 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Robert Ramey</span> to <span class="trac-author">Matthias Troyer</span> </li> </ul> <p> Matias - could you take a look at this one please? </p> <p> Robert Ramey </p> Ticket dgt@… Thu, 10 Apr 2008 00:06:01 GMT <link>https://svn.boost.org/trac10/ticket/1778#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1778#comment:3</guid> <description> <p> It seems that the code I need was commented out here <a class="changeset" href="https://svn.boost.org/trac10/changeset/34068" title="Attempt at fix for MSVC ">[34068]</a>. If this was just accidental as part of the MSVC 0-length array fix, I can simply copy the code into my own sources until Boost 1.35.1 is released. Otherwise, I can only assume it was commented out because there is a problem with it. </p> </description> <category>Ticket</category> </item> <item> <author>dgt@…</author> <pubDate>Thu, 10 Apr 2008 00:20:57 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/1778#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1778#comment:4</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/1778#comment:3" title="Comment 3">dgt@acm.org</a>: </p> <blockquote class="citation"> <p> It seems that the code I need was commented out here <a class="changeset" href="https://svn.boost.org/trac10/changeset/34068" title="Attempt at fix for MSVC ">[34068]</a>. If this was just accidental as part of the MSVC 0-length array fix, I can simply copy the code into my own sources until Boost 1.35.1 is released. Otherwise, I can only assume it was commented out because there is a problem with it. </p> </blockquote> <p> I take that back. That code doesn't help. It looks like the previous behavior can only be attained by copying the data into a nested structure such as: </p> <pre class="wiki">vector&lt; vector&lt;char&gt; &gt; c; ar &amp; make_nvp( "blah", c ); </pre><p> Or write my own wrapper class. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Matthias Troyer</dc:creator> <pubDate>Fri, 25 Apr 2008 06:24:43 GMT</pubDate> <title>status, milestone changed https://svn.boost.org/trac10/ticket/1778#comment:5 https://svn.boost.org/trac10/ticket/1778#comment:5 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.35.1</span> </li> </ul> Ticket Matthias Troyer Sat, 14 Jun 2008 20:28:28 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/1778#comment:6 https://svn.boost.org/trac10/ticket/1778#comment:6 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> Fixed on the trunk </p> Ticket Mon, 03 Nov 2008 14:20:34 GMT milestone deleted https://svn.boost.org/trac10/ticket/1778#comment:7 https://svn.boost.org/trac10/ticket/1778#comment:7 <ul> <li><strong>milestone</strong> <span class="trac-field-deleted">Boost 1.35.1</span> </li> </ul> <p> Milestone Boost 1.35.1 deleted </p> Ticket