[serialization] RTTI issue with non-polymorphic types

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[serialization] RTTI issue with non-polymorphic types

Boost - Dev mailing list
Hi
I am trying to use the serialization library for non-polymorphic types
without RTTI. In release mode everything works fine, but in debug mode there
are problems because dynamic_cast is used for debugging purposes.
The code is in smart_cast.hpp, starting in line 87:

                #if ! defined(NDEBUG)                               \
                || defined(__MWERKS__)
                    // do a checked dynamic cast
                    return cross::cast(u);
                #else

I believe the first line could be replaced with:

                #if (! defined(NDEBUG) && ! defined(BOOST_NO_RTTI) )  \

Is this something you are willing to consider? I decided to ask before
creating any ticket or pull request because there is a number of previous
attempts to make serialization work without RTTI for the general case.
But this is specific for non-polymorphic types.
Thanks.

Jorge


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: [serialization] RTTI issue with non-polymorphic types

Boost - Dev mailing list
On 3/5/18 9:03 AM, Jorge Lodos via Boost wrote:

> Hi
> I am trying to use the serialization library for non-polymorphic types
> without RTTI. In release mode everything works fine, but in debug mode there
> are problems because dynamic_cast is used for debugging purposes.
> The code is in smart_cast.hpp, starting in line 87:
>
>                  #if ! defined(NDEBUG)                               \
>                  || defined(__MWERKS__)
>                      // do a checked dynamic cast
>                      return cross::cast(u);
>                  #else
>
> I believe the first line could be replaced with:
>
>                  #if (! defined(NDEBUG) && ! defined(BOOST_NO_RTTI) )  \
>
> Is this something you are willing to consider? I decided to ask before
> creating any ticket or pull request because there is a number of previous
> attempts to make serialization work without RTTI for the general case.
> But this is specific for non-polymorphic types.
> Thanks.

This as an excellent and useful observation.  I extra efforts to be sure
that the serialization library worked without RTTI being enabled.  In
then end I couldn't make it work.  So definitely make a PR or ticket for
this.  You might want to include an update in the documentation in the
PR.  Also, since you're put your finger on the issue, maybe there is a
tweak that could be made so that serialization of polymorphic types
might be supported as well.

Robert Ramey



>
> Jorge
>
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: [serialization] RTTI issue with non-polymorphic types

Boost - Dev mailing list
>
> Also, since you're put your finger on the issue, maybe there is a
> tweak that could be made so that serialization of polymorphic types
> might be supported as well.
>
> Robert Ramey
>

I'm not sure exactly what's required for serialization, but it might be
possible to add support through some of the facilities in Boost.TypeIndex
that provide a type of RTTI emulation.

-- chris

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: [serialization] RTTI issue with non-polymorphic types

Boost - Dev mailing list
On 3/5/18 10:34 AM, Chris Glover via Boost wrote:

>>
>> Also, since you're put your finger on the issue, maybe there is a
>> tweak that could be made so that serialization of polymorphic types
>> might be supported as well.
>>
>> Robert Ramey
>>
>
> I'm not sure exactly what's required for serialization, but it might be
> possible to add support through some of the facilities in Boost.TypeIndex
> that provide a type of RTTI emulation.

actually the serialization library has it's own type tracking facility
when predated Boost.TypeIndex for many years.  It's called
extended_type_info. But in any case, I'm guessing that your guess that
this might be related to the difficulty in serialization polymorphic
types without RTTI might be related.  But I've never been able to
justify the time to track it all down.

>
> -- chris
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost