f2 call is I think UB - `a` is evaluated before the call to f2, because it's a qualified function call.
the p() calls are all OK I think.

On Sat, Jan 4, 2025 at 9:29 PM Andre Kostur via Std-Proposals <std-proposals@lists.isocpp.org> wrote:
Afraid you’re in the wrong place.  This mailing list is about proposals to change the language, not as a helpdesk.  Reddit might be a better place to ask.

On Sat, Jan 4, 2025 at 1:26 PM 李 秋逸 via Std-Proposals <std-proposals@lists.isocpp.org> wrote:
Hello everyone. I hava a small and maybe useless question about the cplusplus standard. Maybe there are some experts can help me. Here is the code.

#include <iostream>
struct A
{
      A(){} // not trivial
      ~A(){}
      void f1()const
      {
            std::cout << this << '\n';
      }
      void f2(this const A& self)
      {
            std::cout << &self << '\n';
      }
};

void f3(const A& a)
{
      std::cout << &a << '\n';
}

int main()
{
      A a{};
      a.~A();
      a.f1(); // UB!
      f3(a); // OK
      a.f2(); // UB or not?
      auto p = &A::f2;
      p(a); // UB or not?
      p = f3;
      p(a); // OK
      new(std::addressof(a))A{}; // OK
}
--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals