[Boost-bugs] [Boost C++ Libraries] #1778: Possible regression in 1.35 serialization of 2D arrays

Subject: [Boost-bugs] [Boost C++ Libraries] #1778: Possible regression in 1.35 serialization of 2D arrays
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2008-04-05 22:05:33


#1778: Possible regression in 1.35 serialization of 2D arrays
------------------------------+---------------------------------------------
 Reporter: dgt_at_[hidden] | Owner: ramey
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: serialization
  Version: Boost 1.35.0 | Severity: Regression
 Keywords: |
------------------------------+---------------------------------------------
 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).

 '''D:\tools\boost\boost_1_35_0\boost/archive/detail/oserializer.hpp(489) :

 error C2440: 'static_cast' : cannot convert from 'const char (*__w64
 )[16]' to 'value_type *''''


 A 2D char array is being serialized as:


 {{{
 char c[5][16];

 ar & make_nvp("c", c);

 }}}

 ----------------------------

 While I don't have but a high-level grasp of MPL, it seems to me that
 remove_all_extents<T>::type is stripping off all the dimensions, which
 causes line 489 to fail.

 If instead, I serialize as:


 {{{
 ar & make_nvp("c", make_array(&c[0], sizeof(c)/sizeof(c[0]) );
 }}}


 It of course works. I can do the following as well:


 {{{
 ar & make_nvp("c", make_array(&c[0][0], sizeof(c)/sizeof(c[0][0]) );
 }}}


 ----------------------------

 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.



 {{{
 template<class T, std::size_t M, std::size_t N>
 inline
 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
 const
 #endif
 array<T[N]> make_array2D( T (& t)[M][N] )
 {
   return array<T[N]>(&t[0], M);
 }


 template<class T, std::size_t M, std::size_t N>
 inline
 #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
 const
 #endif
 array<T> make_array2D_flatten( T (& t)[M][N])
 {
    return array<T>(static_cast<T*>(&t[0][0]), N*M);
 }

 }}}

 ---------------------------------

 Anyways, just thought I'd let you know what I've run into.

--
Ticket URL: <http://svn.boost.org/trac/boost/ticket/1778>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.


This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:57 UTC