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

--- Comment #4 from Sławomir Fraś <boskidialer at gmail dot com> ---
Not sure if that hints at the possible cause, when i extracted `this` variable
out of the loop to something like this (https://godbolt.org/z/8ebb5E1qG):

    Target* first = this;
    while (first->next)
    {
      Base* n = first->next;

Then the code behaves the same as faulty code, but when i changed it into this
(https://godbolt.org/z/7o58Y4fEq):

    Base* first = this; // only change: Target -> Base
    while (first->next)
    {
      Base* n = first->next;

Then the code works fine even with the `always_inline` on the destructor. In
this case it looks like write to `Base::next` member is not considered as
invalidating value of `Target::next` in register even when it should since
Target derives from the Base class.

Reply via email to