On Sun, Nov 9, 2025 at 10:01 AM Frederick Virchanza Gotham wrote:
>
> In the new compiler, I have
> added a new built-in function called '__builtin_restart_lifetime'
> but I haven't got it working quite perfectly yet


I have further edited my compiler patch, and now
__builtin_restart_lifetime runs without crashing. It still doesn't do
its job properly though as the following crashes:

    struct Monkey {
        int n;
        Monkey(int const arg) : n(arg) {}
        virtual void Func(void);
    };

    struct BigMonkey : virtual Monkey {
        using Monkey::Monkey;
    };

    struct Monkies {
        Monkey m;
        BigMonkey bm;
        Monkies(int const arg) : m(arg), bm(arg) {}
    };

    extern void Invoke(Monkey &m);

    int main(int const argc, char **const argv)
    {
        Monkies mm(argc);
        alignas(Monkies) char unsigned buf[ sizeof(Monkies) ];
        std::memcpy( &buf, &mm, sizeof buf );
        Monkies &mm2 = *static_cast<Monkies*>( static_cast<void*>( &buf ) );
        std::restart_lifetime(&mm,&mm2);
        Invoke( mm2.bm );
    }

The invocation of 'restart_lifetime' should have edited all of the
vptrs of all the base class objects and member objects, but
something's wrong. My code is in "gcc/cp/cp-gimplify.cc", which you
can see here:

    
https://github.com/gcc-mirror/gcc/compare/trunk...healytpk:gcc-vptr-xor:trunk#diff-48a45f1c6b1a7f71bc37f9e0dd75a54645b0e95fa9c9632af9147b926076e2df

Can anyone spot what might be wrong?

Reply via email to