Date: Sat, 4 Jan 2025 21:44:25 +0000
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_at_[hidden]> 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_at_[hidden]> 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_at_[hidden]
>> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
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_at_[hidden]> 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_at_[hidden]> 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_at_[hidden]
>> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
Received on 2025-01-04 21:44:39