https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77896

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Ryan Johnson from comment #4)
>    puts("\nWorks ok-ish:");
>    Jekyl* x = new Jekyl;
>    whatami(x);
>    puts("\nJekyl?");
>    delete x;

I think this would be OK if it did "delete (AlterEgo*)x" ... as written, I'm
not sure.

>    puts("\nBad idea:");
>    Jekyl j;
>    j.toggle();
>    j.toggle();
>    whatami(&j);

This is undefined, because ~Jekyl is going to run on the stack object at the
end of the scope, but it's not a Jekyl at that point.

The bound member functions extension can be used to avoid repeated vtable
lookups for the same function:
https://gcc.gnu.org/onlinedocs/gcc/Bound-member-functions.html

Reply via email to