boost serialization crash with clang 5.0.0


I tried to upgrade to clang 5.0.0 and found that a program that uses
the boost serialization library crashes with a null pointer
dereference during serialization.

The relevant part of boost serialization (from
serialization/oserializer.hpp at develop · boostorg/serialization · GitHub)

    template<class T>
    static const basic_pointer_oserializer * register_type(Archive
&ar, T & /*t*/){
        // there should never be any need to save an abstract polymorphic
        // class pointer. Inhibiting code generation for this
        // permits abstract base classes to be used - note: exception
        // virtual serialize functions used for plug-ins
            typename mpl::eval_if<
                boost::serialization::is_abstract< T >,
            >::type typex;
        return typex::template register_type< T >(ar);

    template<class TPtr>
    static void invoke(Archive &ar, const TPtr t){
        register_type(ar, * t);
        if(NULL == t){
            basic_oarchive & boa

[1] and [2] seems to be related to your case. I try add
-fcatch-undefined-behavior on Compiler Explorer , and get
compilation failure. If the code does have undefined behavior, the
code should be fixed.

[1] What Every C Programmer Should Know About Undefined Behavior #2/3 - The LLVM Project Blog
[2] Finding Undefined Behavior Bugs by Finding Dead Code – Embedded in Academia