C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Possible deprecation of -> operator

From: Tiago Freire <tmiguelf_at_[hidden]>
Date: Mon, 10 Feb 2025 10:26:15 +0000
Can you write such an application and run it?

Sure, it’s invalid. So what?

Stating that it is “not valid C++” it is not useful, in general you don’t try to write invalid code intentionally.
But it happens anyways, and if you can do it by writing plain C++, and it spits out an application that you can run in a computer.

Yeah, it may blow up as you run it. You can call it “invalid”… ok, the same way you can call it a “fish”.
But it has never stopped such an application from existing or even running.
And that was the point, it is not stopping you from writing invalid code.
So, it is better that when you change something that you know where to put the checks right? So that you don’t accidentally write that invalid code?


From: Std-Proposals <std-proposals-bounces_at_[hidden]> On Behalf Of Sebastian Wittmeier via Std-Proposals
Sent: Monday, February 10, 2025 11:06 AM
To: std-proposals_at_[hidden]
Cc: Sebastian Wittmeier <wittmeier_at_[hidden]>
Subject: Re: [std-proposals] Possible deprecation of -> operator


A buggy program in general can be valid.

A UB program is not valid.



A pointer can be nullptr, as long as it is never dereferenced.

A reference cannot refer to an object with an address of nullptr.

Such a program is not a valid C++ program.

-----Ursprüngliche Nachricht-----
Von: Tiago Freire <tmiguelf_at_[hidden]<mailto:tmiguelf_at_[hidden]>>
Gesendet: Mo 10.02.2025 10:44
Betreff: RE: [std-proposals] Possible deprecation of -> operator
An: std-proposals_at_[hidden]<mailto:std-proposals_at_[hidden]>;
CC: Sebastian Wittmeier <wittmeier_at_[hidden]<mailto:wittmeier_at_[hidden]>>;

> It is not possible to write a valid C++ program, where the address of a reference is the nullptr.


Never heard of that. I guess that depends on your definition of valid, if writing bugs is not a “valid” C++ program, but there’s nothing stopping you from writing them.

And it has never stopped me from catching exactly this bug many times. I’ve even given you an example on how to do exactly this on my previous email.

Received on 2025-02-10 10:26:19